⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tables.tex

📁 著名的大规模线性规划求解器源码GLPK.C语言版本,可以修剪.内有详细帮助文档.
💻 TEX
📖 第 1 页 / 共 2 页
字号:
part of the field should be coded twice. For example:\begin{verbatim}"aaa","b""bb","ccc"\n\end{verbatim}The following is a complete example of the data table in CSV format:\begin{verbatim}FROM,TO,DISTANCE,COSTSeattle,New-York,2.5,0.12Seattle,Chicago,1.7,0.08Seattle,Topeka,1.8,0.09San-Diego,New-York,2.5,0.15San-Diego,Chicago,1.8,0.10San-Diego,Topeka,1.4,0.07\end{verbatim}\subsection*{xBASE table driver}The xBASE table driver assumes that the data table is stored in the.dbf file format.To choose the xBASE table driver its name in the table statement shouldbe specified as \verb|"xBASE"|, and the first argument should specifythe name of a .dbf file containing the table. For the output table thereshould be the second argument defining the table format in the form\verb|"FF...F"|, where \verb|F| is either {\tt C({\it n})},which specifies a character field of length $n$, or{\tt N({\it n}{\rm [},{\it p}{\rm ]})}, which specifies a numeric fieldof length $n$ and precision $p$ (by default $p$ is 0).The following is a simple example which illustrates creating andreading a .dbf file:\begin{verbatim}table tab1{i in 1..10} OUT "xBASE" "foo.dbf"   "N(5)N(10,4)C(1)C(10)": 2*i+1 ~ B, Uniform(-20,+20) ~ A,   "?" ~ FOO, "[" & i & "]" ~ C;set S, dimen 4;table tab2 IN "xBASE" "foo.dbf": S <- [B, C, RECNO, A];display S;end;\end{verbatim}\subsection*{ODBC table driver}The ODBC table driver allows connecting to SQL databases using animplementation of the ODBC interface based on the Call Level Interface(CLI).\footnote{The corresponding software standard is defined inISO/IEC 9075-3:2003.}\paragraph{Debian GNU/Linux.}Under Debian GNU/Linux the ODBC table driver uses the iODBCpackage,\footnote{See {\tt<http://www.iodbc.org/>}.} which should beinstalled before building the GLPK package. The installation can beeffected with the following command:\begin{verbatim}sudo apt-get install libiodbc2-dev\end{verbatim}Note that on configuring the GLPK package to enable using the iODBClibrary the option `\verb|--enable-odbc|' should be passed to theconfigure script.The individual databases must be entered for systemwide usage in\linebreak \verb|/etc/odbc.ini| and \verb|/etc/odbcinst.ini|. Databaseconnections to be used by a single user are specified by files in thehome directory (\verb|.odbc.ini| and \verb|.odbcinst.ini|).\paragraph{Microsoft Windows.}Under Microsoft Windows the ODBC table driver uses the Microsoft ODBClibrary. To enable this feature the symbol:\begin{verbatim}#define ODBC_DLNAME "odbc32.dll"\end{verbatim}\noindentshould be defined in the GLPK configuration file `\verb|config.h|'.Data sources can be created via the Administrative Tools from theControl Panel.\bigskipTo choose the ODBC table driver its name in the table statement shouldbe specified as \verb|'ODBC'| or \verb|'iODBC'|.The argument list is specified as follows.The first argument is the connection string passed to the ODBC library,for example:\verb|'DSN=glpk;UID=user;PWD=password'|, or\verb|'DRIVER=MySQL;DATABASE=glpkdb;UID=user;PWD=password'|.Different parts of the string are separated by semicolons. Each partconsists of a pair {\it fieldname} and {\it value} separated by theequal sign. Allowable fieldnames depend on the ODBC library. Typicallythe following fieldnames are allowed:\verb|DATABASE | database;\verb|DRIVER   | ODBC driver;\verb|DSN      | name of a data source;\verb|FILEDSN  | name of a file data source;\verb|PWD      | user password;\verb|SERVER   | database;\verb|UID      | user name.The second argument and all following but the last one are consideredto be SQL statements that shall be executed directly.For IN-table the last argument can be a SELECT command starting withthe capitalized letters \verb|'SELECT '|. If the string does not startwith \verb|'SELECT '| it is considered to be a table name and a SELECTstatement is automatically generated.For OUT-table the last argument can contain one or multiple questionmarks. If it contains a question mark it is considered a template forthe write routine. Otherwise the string is considered a table name andan INSERT template is automatically generated.The writing routine uses the template with the question marks andreplaces the first question mark by the first output parameter, thesecond question mark by the second output parameter and so forth. Thenthe SQL command is issued.The following is an example of the output table statement:\begin{small}\begin{verbatim}table ta { l in LOCATIONS } OUT    'ODBC'   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'   'DROP TABLE IF EXISTS result'   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE )'   'INSERT INTO result VALUES ( 4, ?, ? )' :   l ~ LOC, quantity[l] ~ QUAN;\end{verbatim}\end{small}\noindentAlternatively it could be written as follows:\begin{small}\begin{verbatim}table ta { l in LOCATIONS } OUT    'ODBC'   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'   'DROP TABLE IF EXISTS result'   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE )'   'result' :   l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;\end{verbatim}\end{small}Using templates with `\verb|?|' supports not only INSERT, but alsoUPDATE, DELETE, etc. For example:\begin{small}\begin{verbatim}table ta { l in LOCATIONS } OUT   'ODBC'   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'   'UPDATE result SET DATE = ' & date & ' WHERE ID = 4'   'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :   quantity[l], l;\end{verbatim}\end{small}\subsection*{MySQL table driver}The MySQL table driver allows connecting to MySQL databases.\paragraph{Debian GNU/Linux.}Under Debian GNU/Linux the MySQL table\linebreak driver uses the MySQLpackage,\footnote{For download development files see{\tt<http://dev.mysql.com/downloads/mysql/>}.} which should be installedbefore building the GLPK package. The installation can be effected withthe following command:\begin{verbatim}sudo apt-get install libmysqlclient15-dev\end{verbatim}Note that on configuring the GLPK package to enable using the MySQLlibrary the option `\verb|--enable-mysql|' should be passed to theconfigure script.\pagebreak\paragraph{Microsoft Windows.}Under Microsoft Windows the MySQL table driver also uses the MySQLlibrary. To enable this feature the symbol:\begin{verbatim}#define MYSQL_DLNAME "libmysql.dll"\end{verbatim}\noindentshould be defined in the GLPK configuration file `\verb|config.h|'.\bigskipTo choose the MySQL table driver its name in the table statement shouldbe specified as \verb|'MySQL'|.The argument list is specified as follows.The first argument specifies how to connect the data base in the DSNstyle, for example:\verb|'Database=glpk;UID=glpk;PWD=gnu'|.Different parts of the string are separated by semicolons. Each partconsists of a pair {\it fieldname} and {\it value} separated by theequal sign. The following fieldnames are allowed:\verb|Server   | server running the database (defaulting to localhost);\verb|Database | name of the database;\verb|UID      | user name;\verb|PWD      | user password;\verb|Port     | port used by the server (defaulting to 3306).The second argument and all following but the last are considered to beSQL statements that shall be executed directly.For IN-table the last argument can be a SELECT command starting withthe capitalized letters \verb|'SELECT '|. If the string does not startwith \verb|'SELECT '| it is considered to be a table name and a SELECTstatement is automatically generated.For OUT-table the last argument can contain one or multiple questionmarks. If it contains a question mark it is considered a template forthe write routine. Otherwise the string is considered a table name andan INSERT template is automatically generated.The writing routine uses the template with the question marks andreplaces the first question mark by the first output parameter, thesecond question mark by the second output parameter and so forth. Thenthe SQL command is issued.The following is an example of the output table statement:\begin{small}\begin{verbatim}table ta { l in LOCATIONS } OUT   'MySQL'   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'   'DROP TABLE IF EXISTS result'   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE )'   'INSERT INTO result VALUES ( 4, ?, ? )' :   l ~ LOC, quantity[l] ~ QUAN;\end{verbatim}\end{small}\noindentAlternatively it could be written as follows:\begin{small}\begin{verbatim}table ta { l in LOCATIONS } OUT   'MySQL'   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'   'DROP TABLE IF EXISTS result'   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE )'   'result' :   l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;\end{verbatim}\end{small}Using templates with `\verb|?|' supports not only INSERT, but alsoUPDATE, DELETE, etc. For example:\begin{small}\begin{verbatim}table ta { l in LOCATIONS } OUT   'MySQL'   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'   'UPDATE result SET DATE = ' & date & ' WHERE ID = 4'   'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :   quantity[l], l;\end{verbatim}\end{small}\vspace{15mm}\begin{center}\rule{40mm}{.5pt}\end{center}\end{document}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -