doc/gmpl.tex
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/doc/gmpl.tex	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,4653 @@
     1.4 +%* gmpl.tex *%
     1.5 +
     1.6 +%***********************************************************************
     1.7 +%  This code is part of GLPK (GNU Linear Programming Kit).
     1.8 +%
     1.9 +%  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
    1.10 +%  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
    1.11 +%  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
    1.12 +%  E-mail: <mao@gnu.org>.
    1.13 +%
    1.14 +%  GLPK is free software: you can redistribute it and/or modify it
    1.15 +%  under the terms of the GNU General Public License as published by
    1.16 +%  the Free Software Foundation, either version 3 of the License, or
    1.17 +%  (at your option) any later version.
    1.18 +%
    1.19 +%  GLPK is distributed in the hope that it will be useful, but WITHOUT
    1.20 +%  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    1.21 +%  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
    1.22 +%  License for more details.
    1.23 +%
    1.24 +%  You should have received a copy of the GNU General Public License
    1.25 +%  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
    1.26 +%***********************************************************************
    1.27 +
    1.28 +\documentclass[10pt]{article}
    1.29 +\usepackage[dvipdfm,linktocpage,colorlinks,linkcolor=blue]{hyperref}
    1.30 +
    1.31 +\begin{document}
    1.32 +
    1.33 +\thispagestyle{empty}
    1.34 +
    1.35 +\begin{center}
    1.36 +
    1.37 +\vspace*{1in}
    1.38 +
    1.39 +\begin{huge}
    1.40 +\sf\bfseries Modeling Language GNU MathProg
    1.41 +\end{huge}
    1.42 +
    1.43 +\vspace{0.5in}
    1.44 +
    1.45 +\begin{LARGE}
    1.46 +\sf Language Reference
    1.47 +\end{LARGE}
    1.48 +
    1.49 +\vspace{0.5in}
    1.50 +
    1.51 +\begin{LARGE}
    1.52 +\sf for GLPK Version 4.45
    1.53 +\end{LARGE}
    1.54 +
    1.55 +\vspace{0.5in}
    1.56 +\begin{Large}
    1.57 +\sf (DRAFT, December 2010)
    1.58 +\end{Large}
    1.59 +
    1.60 +\end{center}
    1.61 +
    1.62 +\newpage
    1.63 +
    1.64 +\vspace*{1in}
    1.65 +
    1.66 +\vfill
    1.67 +
    1.68 +\noindent
    1.69 +The GLPK package is part of the GNU Project released under the aegis of
    1.70 +GNU.
    1.71 +
    1.72 +\medskip\noindent
    1.73 +Copyright \copyright{} 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
    1.74 +2008, 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
    1.75 +Moscow Aviation Institute, Moscow, Russia. All rights reserved.
    1.76 +
    1.77 +\medskip\noindent
    1.78 +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
    1.79 +MA 02110-1301, USA.
    1.80 +
    1.81 +\medskip\noindent
    1.82 +Permission is granted to make and distribute verbatim copies of this
    1.83 +manual provided the copyright notice and this permission notice are
    1.84 +preserved on all copies.
    1.85 +
    1.86 +\medskip\noindent
    1.87 +Permission is granted to copy and distribute modified versions of this
    1.88 +manual under the conditions for verbatim copying, provided also that
    1.89 +the entire resulting derived work is distributed under the terms of
    1.90 +a permission notice identical to this one.
    1.91 +
    1.92 +\medskip\noindent
    1.93 +Permission is granted to copy and distribute translations of this
    1.94 +manual into another language, under the above conditions for modified
    1.95 +versions.
    1.96 +
    1.97 +\newpage
    1.98 +
    1.99 +\tableofcontents
   1.100 +
   1.101 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   1.102 +
   1.103 +\newpage
   1.104 +
   1.105 +\section{Introduction}
   1.106 +
   1.107 +{\it GNU MathProg} is a modeling language intended for describing
   1.108 +linear mathematical programming models.\footnote{The GNU MathProg
   1.109 +language is a subset of the AMPL language. Its GLPK implementation is
   1.110 +mainly based on the paper: {\it Robert Fourer}, {\it David M. Gay}, and
   1.111 +{\it Brian W. Kernighan}, ``A Modeling Language for Mathematical
   1.112 +Programming.'' {\it Management Science} 36 (1990)\linebreak pp. 519-54.}
   1.113 +
   1.114 +Model descriptions written in the GNU MathProg language consist of
   1.115 +a set of statements and data blocks constructed by the user from the
   1.116 +language elements described in this document.
   1.117 +
   1.118 +In a process called {\it translation}, a program called the {\it model
   1.119 +translator} analyzes the model description and translates it into
   1.120 +internal data structures, which may be then used either for generating
   1.121 +mathematical programming problem instance or directly by a program
   1.122 +called the {\it solver} to obtain numeric solution of the problem.
   1.123 +
   1.124 +\subsection{Linear programming problem}
   1.125 +\label{problem}
   1.126 +
   1.127 +In MathProg the linear programming (LP) problem is stated as follows:
   1.128 +
   1.129 +\medskip
   1.130 +
   1.131 +\noindent\hspace{.7in}minimize (or maximize)
   1.132 +$$z=c_1x_1+c_2x_2+\dots+c_nx_n+c_0\eqno(1.1)$$
   1.133 +\noindent\hspace{.7in}subject to linear constraints
   1.134 +$$
   1.135 +\begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }l}
   1.136 +L_1&\leq&a_{11}x_1&+&a_{12}x_2&+\dots+&a_{1n}x_n&\leq&U_1\\
   1.137 +L_2&\leq&a_{21}x_1&+&a_{22}x_2&+\dots+&a_{2n}x_n&\leq&U_2\\
   1.138 +\multicolumn{9}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
   1.139 +L_m&\leq&a_{m1}x_1&+&a_{m2}x_2&+\dots+&a_{mn}x_n&\leq&U_m\\
   1.140 +\end{array}\eqno(1.2)
   1.141 +$$
   1.142 +\noindent\hspace{.7in}and bounds of variables
   1.143 +$$
   1.144 +\begin{array}{l@{\ }c@{\ }c@{\ }c@{\ }l}
   1.145 +l_1&\leq&x_1&\leq&u_1\\
   1.146 +l_2&\leq&x_2&\leq&u_2\\
   1.147 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .}\\
   1.148 +l_n&\leq&x_n&\leq&u_n\\
   1.149 +\end{array}\eqno(1.3)
   1.150 +$$
   1.151 +where $x_1$, $x_2$, \dots, $x_n$ are variables; $z$ is the objective
   1.152 +function; $c_1$, $c_2$, \dots, $c_n$ are objective coefficients; $c_0$
   1.153 +is the constant term (``shift'') of the objective function; $a_{11}$,
   1.154 +$a_{12}$, \dots, $a_{mn}$ are constraint coefficients; $L_1$, $L_2$,
   1.155 +\dots, $L_m$ are lower constraint bounds; $U_1$, $U_2$, \dots, $U_m$
   1.156 +are upper constraint bounds; $l_1$, $l_2$, \dots, $l_n$ are lower
   1.157 +bounds of variables; $u_1$, $u_2$, \dots, $u_n$ are upper bounds of
   1.158 +variables.
   1.159 +
   1.160 +Bounds of variables and constraint bounds can be finite as well as
   1.161 +infinite. Besides, lower bounds can be equal to corresponding upper
   1.162 +bounds. Thus, the following types of variables and constraints are
   1.163 +allowed:
   1.164 +
   1.165 +\newpage
   1.166 +
   1.167 +\begin{tabular}{@{}r@{\ }c@{\ }c@{\ }c@{\ }l@{\hspace*{38pt}}l}
   1.168 +$-\infty$&$<$&$x$&$<$&$+\infty$&Free (unbounded) variable\\
   1.169 +$l$&$\leq$&$x$&$<$&$+\infty$&Variable with lower bound\\
   1.170 +$-\infty$&$<$&$x$&$\leq$&$u$&Variable with upper bound\\
   1.171 +$l$&$\leq$&$x$&$\leq$&$u$&Double-bounded variable\\
   1.172 +$l$&$=$&$x$&=&$u$&Fixed variable\\
   1.173 +\end{tabular}
   1.174 +
   1.175 +\bigskip
   1.176 +
   1.177 +\begin{tabular}{@{}r@{\ }c@{\ }c@{\ }c@{\ }ll}
   1.178 +$-\infty$&$<$&$\sum a_jx_j$&$<$&$+\infty$&Free (unbounded) linear
   1.179 +form\\
   1.180 +$L$&$\leq$&$\sum a_jx_j$&$<$&$+\infty$&Inequality constraint ``greater
   1.181 +than or equal to''\\
   1.182 +$-\infty$&$<$&$\sum a_jx_j$&$\leq$&$U$&Inequality constraint ``less
   1.183 +than or equal to''\\
   1.184 +$L$&$\leq$&$\sum a_jx_j$&$\leq$&$U$&Double-bounded inequality
   1.185 +constraint\\
   1.186 +$L$&$=$&$\sum a_jx_j$&=&$U$&Equality constraint\\
   1.187 +\end{tabular}
   1.188 +
   1.189 +\bigskip
   1.190 +
   1.191 +In addition to pure LP problems MathProg also allows mixed integer
   1.192 +linear programming (MIP) problems, where some or all variables are
   1.193 +restricted to be integer or binary.
   1.194 +
   1.195 +\subsection{Model objects}
   1.196 +
   1.197 +In MathProg the model is described in terms of sets, parameters,
   1.198 +variables, constraints, and objectives, which are called {\it model
   1.199 +objects}.
   1.200 +
   1.201 +The user introduces particular model objects using the language
   1.202 +statements. Each model object is provided with a symbolic name that
   1.203 +uniquely identifies the object and is intended for referencing purposes.
   1.204 +
   1.205 +Model objects, including sets, can be multidimensional arrays built
   1.206 +over indexing sets. Formally, $n$-dimensional array $A$ is the mapping:
   1.207 +$$A:\Delta\rightarrow\Xi,\eqno(1.4)$$
   1.208 +where $\Delta\subseteq S_1\times\dots\times S_n$ is a subset of the
   1.209 +Cartesian product of indexing sets,\linebreak $\Xi$ is a set of array members.
   1.210 +In MathProg the set $\Delta$ is called the {\it subscript domain}. Its
   1.211 +members are $n$-tuples $(i_1,\dots,i_n)$, where $i_1\in S_1$, \dots,
   1.212 +$i_n\in S_n$.
   1.213 +
   1.214 +If $n=0$, the Cartesian product above has exactly one member (namely,
   1.215 +\linebreak 0-tuple), so it is convenient to think scalar objects as
   1.216 +0-dimensional arrays having one member.
   1.217 +
   1.218 +The type of array members is determined by the type of corresponding
   1.219 +model object as follows:
   1.220 +
   1.221 +\medskip
   1.222 +
   1.223 +\noindent\hfil
   1.224 +\begin{tabular}{@{}ll@{}}
   1.225 +Model object&Array member\\
   1.226 +\hline
   1.227 +Set&Elemental plain set\\
   1.228 +Parameter&Number or symbol\\
   1.229 +Variable&Elemental variable\\
   1.230 +Constraint&Elemental constraint\\
   1.231 +Objective&Elemental objective\\
   1.232 +\end{tabular}
   1.233 +
   1.234 +\medskip
   1.235 +
   1.236 +In order to refer to a particular object member the object should be
   1.237 +provided with {\it subscripts}. For example, if $a$ is a 2-dimensional
   1.238 +parameter defined over $I\times J$, a reference to its particular
   1.239 +member can be written as $a[i,j]$, where $i\in I$ and $j\in J$. It is
   1.240 +understood that scalar objects being 0-dimensional need no subscripts.
   1.241 +
   1.242 +\subsection{Structure of model description}
   1.243 +
   1.244 +It is sometimes desirable to write a model which, at various points,
   1.245 +may require different data for each problem instance to be solved using
   1.246 +that model. For this reason in MathProg the model description consists
   1.247 +of two parts: the {\it model section} and the {\it data section}.
   1.248 +
   1.249 +The model section is a main part of the model description that contains
   1.250 +declarations of model objects and is common for all problems based on
   1.251 +the corresponding model.
   1.252 +
   1.253 +The data section is an optional part of the model description that
   1.254 +contains data specific for a particular problem instance.
   1.255 +
   1.256 +Depending on what is more convenient the model and data sections can be
   1.257 +placed either in one file or in two separate files. The latter feature
   1.258 +allows having arbitrary number of different data sections to be used
   1.259 +with the same model section.
   1.260 +
   1.261 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   1.262 +
   1.263 +\newpage
   1.264 +
   1.265 +\section{Coding model description}
   1.266 +\label{coding}
   1.267 +
   1.268 +The model description is coded in plain text format using ASCII
   1.269 +character set. Characters valid in the model description are the
   1.270 +following:
   1.271 +
   1.272 +\begin{itemize}
   1.273 +\item alphabetic characters:\\
   1.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|\\
   1.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 _|
   1.276 +\item numeric characters:\\
   1.277 +\verb|0 1 2 3 4 5 6 7 8 9|
   1.278 +\item special characters:\\
   1.279 +\verb?! " # & ' ( ) * + , - . / : ; < = > [ ] ^ { | }?
   1.280 +\item white-space characters:\\
   1.281 +\verb|SP HT CR NL VT FF|
   1.282 +\end{itemize}
   1.283 +
   1.284 +Within string literals and comments any ASCII characters (except
   1.285 +control characters) are valid.
   1.286 +
   1.287 +White-space characters are non-significant. They can be used freely
   1.288 +between lexical units to improve readability of the model description.
   1.289 +They are also used to separate lexical units from each other if there
   1.290 +is no other way to do that.
   1.291 +
   1.292 +Syntactically model description is a sequence of lexical units in the
   1.293 +following categories:
   1.294 +
   1.295 +\begin{itemize}
   1.296 +\item symbolic names;
   1.297 +\item numeric literals;
   1.298 +\item string literals;
   1.299 +\item keywords;
   1.300 +\item delimiters;
   1.301 +\item comments.
   1.302 +\end{itemize}
   1.303 +
   1.304 +The lexical units of the language are discussed below.
   1.305 +
   1.306 +\subsection{Symbolic names}
   1.307 +
   1.308 +A {\it symbolic name} consists of alphabetic and numeric characters,
   1.309 +the first of which must be alphabetic. All symbolic names are distinct
   1.310 +(case sensitive).
   1.311 +
   1.312 +\medskip
   1.313 +
   1.314 +\noindent{\bf Examples}
   1.315 +
   1.316 +\medskip
   1.317 +
   1.318 +\noindent\verb|alpha123|
   1.319 +
   1.320 +\noindent\verb|This_is_a_name|
   1.321 +
   1.322 +\noindent\verb|_P123_abc_321|
   1.323 +
   1.324 +\newpage
   1.325 +
   1.326 +Symbolic names are used to identify model objects (sets, parameters,
   1.327 +variables, constraints, objectives) and dummy indices.
   1.328 +
   1.329 +All symbolic names (except names of dummy indices) must be unique, i.e.
   1.330 +the model description must have no objects with identical names.
   1.331 +Symbolic names of dummy indices must be unique within the scope, where
   1.332 +they are valid.
   1.333 +
   1.334 +\subsection{Numeric literals}
   1.335 +
   1.336 +A {\it numeric literal} has the form {\it xx}{\tt E}{\it syy}, where
   1.337 +{\it xx} is a number with optional decimal point, {\it s} is the sign
   1.338 +{\tt+} or {\tt-}, {\it yy} is a decimal exponent. The letter {\tt E} is
   1.339 +case insensitive and can be coded as {\tt e}.
   1.340 +
   1.341 +\medskip
   1.342 +
   1.343 +\noindent{\bf Examples}
   1.344 +
   1.345 +\medskip
   1.346 +
   1.347 +\noindent\verb|123|
   1.348 +
   1.349 +\noindent\verb|3.14159|
   1.350 +
   1.351 +\noindent\verb|56.E+5|
   1.352 +
   1.353 +\noindent\verb|.78|
   1.354 +
   1.355 +\noindent\verb|123.456e-7|
   1.356 +
   1.357 +\medskip
   1.358 +
   1.359 +Numeric literals are used to represent numeric quantities. They have
   1.360 +obvious fixed meaning.
   1.361 +
   1.362 +\subsection{String literals}
   1.363 +
   1.364 +A {\it string literal} is a sequence of arbitrary characters enclosed
   1.365 +either in single quotes or in double quotes. Both these forms are
   1.366 +equivalent.
   1.367 +
   1.368 +If the single quote is part of a string literal enclosed in single
   1.369 +quotes, it must be coded twice. Analogously, if the double quote is
   1.370 +part of a string literal enclosed in double quotes, it must be coded
   1.371 +twice.
   1.372 +
   1.373 +\medskip
   1.374 +
   1.375 +\noindent{\bf Examples}
   1.376 +
   1.377 +\medskip
   1.378 +
   1.379 +\noindent\verb|'This is a string'|
   1.380 +
   1.381 +\noindent\verb|"This is another string"|
   1.382 +
   1.383 +\noindent\verb|'1 + 2 = 3'|
   1.384 +
   1.385 +\noindent\verb|'That''s all'|
   1.386 +
   1.387 +\noindent\verb|"She said: ""No"""|
   1.388 +
   1.389 +\medskip
   1.390 +
   1.391 +String literals are used to represent symbolic quantities.
   1.392 +
   1.393 +\subsection{Keywords}
   1.394 +
   1.395 +A {\it keyword} is a sequence of alphabetic characters and possibly
   1.396 +some special characters.
   1.397 +
   1.398 +All keywords fall into two categories: {\it reserved keywords}, which
   1.399 +cannot be used as symbolic names, and {\it non-reserved keywords},
   1.400 +which being recognized by context can be used as symbolic names.
   1.401 +
   1.402 +\newpage
   1.403 +
   1.404 +The reserved keywords are the following:
   1.405 +
   1.406 +\medskip
   1.407 +
   1.408 +\noindent\hfil
   1.409 +\begin{tabular}{@{}p{.7in}p{.7in}p{.7in}p{.7in}@{}}
   1.410 +{\tt and}&{\tt else}&{\tt mod}&{\tt union}\\
   1.411 +{\tt by}&{\tt if}&{\tt not}&{\tt within}\\
   1.412 +{\tt cross}&{\tt in}&{\tt or}\\
   1.413 +{\tt diff}&{\tt inter}&{\tt symdiff}\\
   1.414 +{\tt div}&{\tt less}&{\tt then}\\
   1.415 +\end{tabular}
   1.416 +
   1.417 +\medskip
   1.418 +
   1.419 +Non-reserved keywords are described in following sections.
   1.420 +
   1.421 +All the keywords have fixed meaning, which will be explained on
   1.422 +discussion of corresponding syntactic constructions, where the keywords
   1.423 +are used.
   1.424 +
   1.425 +\subsection{Delimiters}
   1.426 +
   1.427 +A {\it delimiter} is either a single special character or a sequence of
   1.428 +two special characters as follows:
   1.429 +
   1.430 +\medskip
   1.431 +
   1.432 +\noindent\hfil
   1.433 +\begin{tabular}{@{}p{.3in}p{.3in}p{.3in}p{.3in}p{.3in}p{.3in}@{}}
   1.434 +{\tt+}&{\tt\textasciicircum}&{\tt==}&{\tt!}&{\tt:}&{\tt)}\\
   1.435 +{\tt-}&{\tt\&}&{\tt>=}&{\tt\&\&}&{\tt;}&{\tt[}\\
   1.436 +{\tt*}&{\tt<}&{\tt>}&{\tt||}&{\tt:=}&{\tt|}\\
   1.437 +{\tt/}&{\tt<=}&{\tt<>}&{\tt.}&{\tt..}&{\tt\{}\\
   1.438 +{\tt**}&{\tt=}&{\tt!=}&{\tt,}&{\tt(}&{\tt\}}\\
   1.439 +\end{tabular}
   1.440 +
   1.441 +\medskip
   1.442 +
   1.443 +If the delimiter consists of two characters, there must be no spaces
   1.444 +between the characters.
   1.445 +
   1.446 +All the delimiters have fixed meaning, which will be explained on
   1.447 +discussion corresponding syntactic constructions, where the delimiters
   1.448 +are used.
   1.449 +
   1.450 +\subsection{Comments}
   1.451 +
   1.452 +For documenting purposes the model description can be provided with
   1.453 +{\it comments}, which may have two different forms. The first form is
   1.454 +a {\it single-line comment}, which begins with the character {\tt\#}
   1.455 +and extends until end of line. The second form is a {\it comment
   1.456 +sequence}, which is a sequence of any characters enclosed within
   1.457 +{\tt/*} and {\tt*/}.
   1.458 +
   1.459 +\medskip
   1.460 +
   1.461 +\noindent{\bf Examples}
   1.462 +
   1.463 +\medskip
   1.464 +
   1.465 +\noindent\verb|param n := 10; # This is a comment|
   1.466 +
   1.467 +\noindent\verb|/* This is another comment */|
   1.468 +
   1.469 +\medskip
   1.470 +
   1.471 +Comments are ignored by the model translator and can appear anywhere in
   1.472 +the model description, where white-space characters are allowed.
   1.473 +
   1.474 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   1.475 +
   1.476 +\newpage
   1.477 +
   1.478 +\section{Expressions}
   1.479 +
   1.480 +An {\it expression} is a rule for computing a value. In model
   1.481 +description expressions are used as constituents of certain statements.
   1.482 +
   1.483 +In general case expressions consist of operands and operators.
   1.484 +
   1.485 +Depending on the type of the resultant value all expressions fall into
   1.486 +the following categories:
   1.487 +
   1.488 +\begin{itemize}
   1.489 +\item numeric expressions;
   1.490 +\item symbolic expressions;
   1.491 +\item indexing expressions;
   1.492 +\item set expressions;
   1.493 +\item logical expressions;
   1.494 +\item linear expressions.
   1.495 +\end{itemize}
   1.496 +
   1.497 +\subsection{Numeric expressions}
   1.498 +
   1.499 +A {\it numeric expression} is a rule for computing a single numeric
   1.500 +value represented as a floating-point number.
   1.501 +
   1.502 +The primary numeric expression may be a numeric literal, dummy index,
   1.503 +unsubscripted parameter, subscripted parameter, built-in function
   1.504 +reference, iterated numeric expression, conditional numeric expression,
   1.505 +or another numeric expression enclosed in parentheses.
   1.506 +
   1.507 +\medskip
   1.508 +
   1.509 +\noindent{\bf Examples}
   1.510 +
   1.511 +\medskip
   1.512 +
   1.513 +\noindent
   1.514 +\begin{tabular}{@{}ll@{}}
   1.515 +\verb|1.23|&(numeric literal)\\
   1.516 +\verb|j|&(dummy index)\\
   1.517 +\verb|time|&(unsubscripted parameter)\\
   1.518 +\verb|a['May 2003',j+1]|&(subscripted parameter)\\
   1.519 +\verb|abs(b[i,j])|&(function reference)\\
   1.520 +\verb|sum{i in S diff T} alpha[i] * b[i,j]|&(iterated expression)\\
   1.521 +\verb|if i in I then 2 * p else q[i+1]|&(conditional expression)\\
   1.522 +\verb|(b[i,j] + .5 * c)|&(parenthesized expression)\\
   1.523 +\end{tabular}
   1.524 +
   1.525 +\medskip
   1.526 +
   1.527 +More general numeric expressions containing two or more primary numeric
   1.528 +expressions may be constructed by using certain arithmetic operators.
   1.529 +
   1.530 +\medskip
   1.531 +
   1.532 +\noindent{\bf Examples}
   1.533 +
   1.534 +\medskip
   1.535 +
   1.536 +\noindent\verb|j+1|
   1.537 +
   1.538 +\noindent\verb|2 * a[i-1,j+1] - b[i,j]|
   1.539 +
   1.540 +\noindent\verb|sum{j in J} a[i,j] * x[j] + sum{k in K} b[i,k] * x[k]|
   1.541 +
   1.542 +\noindent\verb|(if i in I then 2 * p else q[i+1]) / (a[i,j] + 1.5)|
   1.543 +
   1.544 +\subsubsection{Numeric literals}
   1.545 +
   1.546 +If the primary numeric expression is a numeric literal, the resultant
   1.547 +value is obvious.
   1.548 +
   1.549 +\subsubsection{Dummy indices}
   1.550 +
   1.551 +If the primary numeric expression is a dummy index, the resultant value
   1.552 +is current value assigned to that dummy index.
   1.553 +
   1.554 +\subsubsection{Unsubscripted parameters}
   1.555 +
   1.556 +If the primary numeric expression is an unsubscripted parameter (which
   1.557 +must be 0-dimensional), the resultant value is the value of that
   1.558 +parameter.
   1.559 +
   1.560 +\subsubsection{Subscripted parameters}
   1.561 +
   1.562 +The primary numeric expression, which refers to a subscripted parameter,
   1.563 +has the following syntactic form:
   1.564 +
   1.565 +\medskip
   1.566 +
   1.567 +\noindent\hfil
   1.568 +{\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
   1.569 +
   1.570 +\medskip
   1.571 +
   1.572 +\noindent where {\it name} is the symbolic name of the parameter,
   1.573 +$i_1$, $i_2$, \dots, $i_n$ are subscripts.
   1.574 +
   1.575 +Each subscript must be a numeric or symbolic expression. The number of
   1.576 +subscripts in the subscript list must be the same as the dimension of
   1.577 +the parameter with which the subscript list is associated.
   1.578 +
   1.579 +Actual values of subscript expressions are used to identify
   1.580 +a particular member of the parameter that determines the resultant
   1.581 +value of the primary expression.
   1.582 +
   1.583 +\subsubsection{Function references}
   1.584 +
   1.585 +In MathProg there exist the following built-in functions which may be
   1.586 +used in numeric expressions:
   1.587 +
   1.588 +\medskip
   1.589 +
   1.590 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
   1.591 +{\tt abs(}$x${\tt)}&$|x|$, absolute value of $x$\\
   1.592 +{\tt atan(}$x${\tt)}&$\arctan x$, principal value of the arc tangent of
   1.593 +$x$ (in radians)\\
   1.594 +{\tt atan(}$y${\tt,} $x${\tt)}&$\arctan y/x$, principal value of the
   1.595 +arc tangent of $y/x$ (in radians). In this case the signs of both
   1.596 +arguments $y$ and $x$ are used to determine the quadrant of the
   1.597 +resultant value\\
   1.598 +{\tt card(}$X${\tt)}&$|X|$, cardinality (the number of elements) of
   1.599 +set $X$\\
   1.600 +{\tt ceil(}$x${\tt)}&$\lceil x\rceil$, smallest integer not less than
   1.601 +$x$ (``ceiling of $x$'')\\
   1.602 +{\tt cos(}$x${\tt)}&$\cos x$, cosine of $x$ (in radians)\\
   1.603 +{\tt exp(}$x${\tt)}&$e^x$, base-$e$ exponential of $x$\\
   1.604 +{\tt floor(}$x${\tt)}&$\lfloor x\rfloor$, largest integer not greater
   1.605 +than $x$ (``floor of $x$'')\\
   1.606 +\end{tabular}
   1.607 +
   1.608 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
   1.609 +{\tt gmtime()}&the number of seconds elapsed since 00:00:00~Jan~1, 1970,
   1.610 +Coordinated Universal Time (for details see Subsection \ref{gmtime},
   1.611 +page \pageref{gmtime})\\
   1.612 +{\tt length(}$s${\tt)}&$|s|$, length of character string $s$\\
   1.613 +{\tt log(}$x${\tt)}&$\log x$, natural logarithm of $x$\\
   1.614 +{\tt log10(}$x${\tt)}&$\log_{10}x$, common (decimal) logarithm of $x$\\
   1.615 +{\tt max(}$x_1${\tt,} $x_2${\tt,} \dots{\tt,} $x_n${\tt)}&the largest
   1.616 +of values $x_1$, $x_2$, \dots, $x_n$\\
   1.617 +{\tt min(}$x_1${\tt,} $x_2${\tt,} \dots{\tt,} $x_n${\tt)}&the smallest
   1.618 +of values $x_1$, $x_2$, \dots, $x_n$\\
   1.619 +{\tt round(}$x${\tt)}&rounding $x$ to nearest integer\\
   1.620 +{\tt round(}$x${\tt,} $n${\tt)}&rounding $x$ to $n$ fractional decimal
   1.621 +digits\\
   1.622 +{\tt sin(}$x${\tt)}&$\sin x$, sine of $x$ (in radians)\\
   1.623 +{\tt sqrt(}$x${\tt)}&$\sqrt{x}$, non-negative square root of $x$\\
   1.624 +{\tt str2time(}$s${\tt,} $f${\tt)}&converting character string $s$ to
   1.625 +calendar time (for details see Subsection \ref{str2time}, page
   1.626 +\pageref{str2time})\\
   1.627 +{\tt trunc(}$x${\tt)}&truncating $x$ to nearest integer\\
   1.628 +{\tt trunc(}$x${\tt,} $n${\tt)}&truncating $x$ to $n$ fractional
   1.629 +decimal digits\\
   1.630 +{\tt Irand224()}&generating pseudo-random integer uniformly distributed
   1.631 +in $[0,2^{24})$\\
   1.632 +{\tt Uniform01()}&generating pseudo-random number uniformly distributed
   1.633 +in $[0,1)$\\
   1.634 +{\tt Uniform(}$a${\tt,} $b${\tt)}&generating pseudo-random number
   1.635 +uniformly distributed in $[a,b)$\\
   1.636 +{\tt Normal01()}&generating Gaussian pseudo-random variate with
   1.637 +$\mu=0$ and $\sigma=1$\\
   1.638 +{\tt Normal(}$\mu${\tt,} $\sigma${\tt)}&generating Gaussian
   1.639 +pseudo-random variate with given $\mu$ and $\sigma$\\
   1.640 +\end{tabular}
   1.641 +
   1.642 +\medskip
   1.643 +
   1.644 +Arguments of all built-in functions, except {\tt card}, {\tt length},
   1.645 +and {\tt str2time}, must be numeric expressions. The argument of
   1.646 +{\tt card} must be a set expression. The argument of {\tt length} and
   1.647 +both arguments of {\tt str2time} must be symbolic expressions.
   1.648 +
   1.649 +The resultant value of the numeric expression, which is a function
   1.650 +reference, is the result of applying the function to its argument(s).
   1.651 +
   1.652 +Note that each pseudo-random generator function has a latent argument
   1.653 +(i.e. some internal state), which is changed whenever the function has
   1.654 +been applied. Thus, if the function is applied repeatedly even to
   1.655 +identical arguments, due to the side effect different resultant values
   1.656 +are always produced.
   1.657 +
   1.658 +\subsubsection{Iterated expressions}
   1.659 +\label{itexpr}
   1.660 +
   1.661 +An {\it iterated numeric expression} is a primary numeric expression,
   1.662 +which has the following syntactic form:
   1.663 +
   1.664 +\medskip
   1.665 +
   1.666 +\noindent\hfil
   1.667 +{\it iterated-operator indexing-expression integrand}
   1.668 +
   1.669 +\medskip
   1.670 +
   1.671 +\noindent where {\it iterated-operator} is the symbolic name of the
   1.672 +iterated operator to be performed (see below), {\it indexing-expression}
   1.673 +is an indexing expression which introduces dummy indices and controls
   1.674 +iterating, {\it integrand} is a numeric expression that participates in
   1.675 +the operation.
   1.676 +
   1.677 +In MathProg there exist four iterated operators, which may be used in
   1.678 +numeric expressions:
   1.679 +
   1.680 +\medskip
   1.681 +
   1.682 +\noindent\hfil
   1.683 +\begin{tabular}{@{}lll@{}}
   1.684 +{\tt sum}&summation&$\displaystyle\sum_{(i_1,\dots,i_n)\in\Delta}
   1.685 +f(i_1,\dots,i_n)$\\
   1.686 +{\tt prod}&production&$\displaystyle\prod_{(i_1,\dots,i_n)\in\Delta}
   1.687 +f(i_1,\dots,i_n)$\\
   1.688 +{\tt min}&minimum&$\displaystyle\min_{(i_1,\dots,i_n)\in\Delta}
   1.689 +f(i_1,\dots,i_n)$\\
   1.690 +{\tt max}&maximum&$\displaystyle\max_{(i_1,\dots,i_n)\in\Delta}
   1.691 +f(i_1,\dots,i_n)$\\
   1.692 +\end{tabular}
   1.693 +
   1.694 +\medskip
   1.695 +
   1.696 +\noindent where $i_1$, \dots, $i_n$ are dummy indices introduced in
   1.697 +the indexing expression, $\Delta$ is the domain, a set of $n$-tuples
   1.698 +specified by the indexing expression which defines particular values
   1.699 +assigned to the dummy indices on performing the iterated operation,
   1.700 +$f(i_1,\dots,i_n)$ is the integrand, a numeric expression whose
   1.701 +resultant value depends on the dummy indices.
   1.702 +
   1.703 +The resultant value of an iterated numeric expression is the result of
   1.704 +applying of the iterated operator to its integrand over all $n$-tuples
   1.705 +contained in the domain.
   1.706 +
   1.707 +\subsubsection{Conditional expressions}
   1.708 +\label{ifthen}
   1.709 +
   1.710 +A {\it conditional numeric expression} is a primary numeric expression,
   1.711 +which has one of the following two syntactic forms:
   1.712 +
   1.713 +\medskip
   1.714 +
   1.715 +\noindent\hfil
   1.716 +{\tt if} $b$ {\tt then} $x$ {\tt else} $y$
   1.717 +
   1.718 +\medskip
   1.719 +
   1.720 +\noindent\hspace{126.5pt}
   1.721 +{\tt if} $b$ {\tt then} $x$
   1.722 +
   1.723 +\medskip
   1.724 +
   1.725 +\noindent where $b$ is an logical expression, $x$ and $y$ are numeric
   1.726 +expressions.
   1.727 +
   1.728 +The resultant value of the conditional expression depends on the value
   1.729 +of the logical expression that follows the keyword {\tt if}. If it
   1.730 +takes on the value {\it true}, the value of the conditional expression
   1.731 +is the value of the expression that follows the keyword {\tt then}.
   1.732 +Otherwise, if the logical expression takes on the value {\it false},
   1.733 +the value of the conditional expression is the value of the expression
   1.734 +that follows the keyword {\it else}. If the second, reduced form of the
   1.735 +conditional expression is used and the logical expression takes on the
   1.736 +value {\it false}, the resultant value of the conditional expression is
   1.737 +zero.
   1.738 +
   1.739 +\subsubsection{Parenthesized expressions}
   1.740 +
   1.741 +Any numeric expression may be enclosed in parentheses that
   1.742 +syntactically makes it a primary numeric expression.
   1.743 +
   1.744 +Parentheses may be used in numeric expressions, as in algebra, to
   1.745 +specify the desired order in which operations are to be performed.
   1.746 +Where parentheses are used, the expression within the parentheses is
   1.747 +evaluated before the resultant value is used.
   1.748 +
   1.749 +The resultant value of the parenthesized expression is the same as the
   1.750 +value of the expression enclosed within parentheses.
   1.751 +
   1.752 +\subsubsection{Arithmetic operators}
   1.753 +
   1.754 +In MathProg there exist the following arithmetic operators, which may
   1.755 +be used in numeric expressions:
   1.756 +
   1.757 +\medskip
   1.758 +
   1.759 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
   1.760 +{\tt +} $x$&unary plus\\
   1.761 +{\tt -} $x$&unary minus\\
   1.762 +$x$ {\tt +} $y$&addition\\
   1.763 +$x$ {\tt -} $y$&subtraction\\
   1.764 +$x$ {\tt less} $y$&positive difference (if $x<y$ then 0 else $x-y$)\\
   1.765 +$x$ {\tt *} $y$&multiplication\\
   1.766 +$x$ {\tt /} $y$&division\\
   1.767 +$x$ {\tt div} $y$&quotient of exact division\\
   1.768 +$x$ {\tt mod} $y$&remainder of exact division\\
   1.769 +$x$ {\tt **} $y$, $x$ {\tt\textasciicircum} $y$&exponentiation (raising
   1.770 +to power)\\
   1.771 +\end{tabular}
   1.772 +
   1.773 +\medskip
   1.774 +
   1.775 +\noindent where $x$ and $y$ are numeric expressions.
   1.776 +
   1.777 +If the expression includes more than one arithmetic operator, all
   1.778 +operators are performed from left to right according to the hierarchy
   1.779 +of operations (see below) with the only exception that the
   1.780 +exponentiaion operators are performed from right to left.
   1.781 +
   1.782 +The resultant value of the expression, which contains arithmetic
   1.783 +operators, is the result of applying the operators to their operands.
   1.784 +
   1.785 +\subsubsection{Hierarchy of operations}
   1.786 +\label{hierarchy}
   1.787 +
   1.788 +The following list shows the hierarchy of operations in numeric
   1.789 +expressions:
   1.790 +
   1.791 +\medskip
   1.792 +
   1.793 +\noindent\hfil
   1.794 +\begin{tabular}{@{}ll@{}}
   1.795 +Operation&Hierarchy\\
   1.796 +\hline
   1.797 +Evaluation of functions ({\tt abs}, {\tt ceil}, etc.)&1st\\
   1.798 +Exponentiation ({\tt**}, {\tt\textasciicircum})&2nd\\
   1.799 +Unary plus and minus ({\tt+}, {\tt-})&3rd\\
   1.800 +Multiplication and division ({\tt*}, {\tt/}, {\tt div}, {\tt mod})&4th\\
   1.801 +Iterated operations ({\tt sum}, {\tt prod}, {\tt min}, {\tt max})&5th\\
   1.802 +Addition and subtraction ({\tt+}, {\tt-}, {\tt less})&6th\\
   1.803 +Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
   1.804 +7th\\
   1.805 +\end{tabular}
   1.806 +
   1.807 +\medskip
   1.808 +
   1.809 +This hierarchy is used to determine which of two consecutive operations
   1.810 +is performed first. If the first operator is higher than or equal to
   1.811 +the second, the first operation is performed. If it is not, the second
   1.812 +operator is compared to the third, etc. When the end of the expression
   1.813 +is reached, all of the remaining operations are performed in the
   1.814 +reverse order.
   1.815 +
   1.816 +\newpage
   1.817 +
   1.818 +\subsection{Symbolic expressions}
   1.819 +
   1.820 +A {\it symbolic expression} is a rule for computing a single symbolic
   1.821 +value represented as a character string.
   1.822 +
   1.823 +The primary symbolic expression may be a string literal, dummy index,
   1.824 +unsubscripted parameter, subscripted parameter, built-in function
   1.825 +reference, conditional symbolic expression, or another symbolic
   1.826 +expression enclosed in parentheses.
   1.827 +
   1.828 +It is also allowed to use a numeric expression as the primary symbolic
   1.829 +expression, in which case the resultant value of the numeric expression
   1.830 +is automatically converted to the symbolic type.
   1.831 +
   1.832 +\medskip
   1.833 +
   1.834 +\noindent{\bf Examples}
   1.835 +
   1.836 +\medskip
   1.837 +
   1.838 +\noindent
   1.839 +\begin{tabular}{@{}ll@{}}
   1.840 +\verb|'May 2003'|&(string literal)\\
   1.841 +\verb|j|&(dummy index)\\
   1.842 +\verb|p|&(unsubscripted parameter)\\
   1.843 +\verb|s['abc',j+1]|&(subscripted parameter)\\
   1.844 +\verb|substr(name[i],k+1,3)|&(function reference)\\
   1.845 +\verb|if i in I then s[i,j] else t[i+1]|&(conditional expression)\\
   1.846 +\verb|((10 * b[i,j]) & '.bis')|&(parenthesized expression)\\
   1.847 +\end{tabular}
   1.848 +
   1.849 +\medskip
   1.850 +
   1.851 +More general symbolic expressions containing two or more primary
   1.852 +symbolic expressions may be constructed by using the concatenation
   1.853 +operator.
   1.854 +
   1.855 +\medskip
   1.856 +
   1.857 +\noindent{\bf Examples}
   1.858 +
   1.859 +\medskip
   1.860 +
   1.861 +\noindent\verb|'abc[' & i & ',' & j & ']'|
   1.862 +
   1.863 +\noindent\verb|"from " & city[i] & " to " & city[j]|
   1.864 +
   1.865 +\medskip
   1.866 +
   1.867 +The principles of evaluation of symbolic expressions are completely
   1.868 +analogous to the ones given for numeric expressions (see above).
   1.869 +
   1.870 +\subsubsection{Function references}
   1.871 +
   1.872 +In MathProg there exist the following built-in functions which may be
   1.873 +used in symbolic expressions:
   1.874 +
   1.875 +\medskip
   1.876 +
   1.877 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
   1.878 +{\tt substr(}$s${\tt,} $x${\tt)}&substring of $s$ starting from
   1.879 +position $x$\\
   1.880 +{\tt substr(}$s${\tt,} $x${\tt,} $y${\tt)}&substring of $s$ starting
   1.881 +from position $x$ and having length $y$\\
   1.882 +{\tt time2str(}$t${\tt,} $f${\tt)}&converting calendar time to
   1.883 +character string (for details see Subsection \ref{time2str}, page
   1.884 +\pageref{time2str})\\
   1.885 +\end{tabular}
   1.886 +
   1.887 +\medskip
   1.888 +
   1.889 +The first argument of {\tt substr} must be a symbolic expression while
   1.890 +its second and optional third arguments must be numeric expressions.
   1.891 +
   1.892 +The first argument of {\tt time2str} must be a numeric expression, and
   1.893 +its second argument must be a symbolic expression.
   1.894 +
   1.895 +The resultant value of the symbolic expression, which is a function
   1.896 +reference, is the result of applying the function to its arguments.
   1.897 +
   1.898 +\subsubsection{Symbolic operators}
   1.899 +
   1.900 +Currently in MathProg there exists the only symbolic operator:
   1.901 +
   1.902 +\medskip
   1.903 +
   1.904 +\noindent\hfil
   1.905 +{\tt s \& t}
   1.906 +
   1.907 +\medskip
   1.908 +
   1.909 +\noindent where $s$ and $t$ are symbolic expressions. This operator
   1.910 +means concatenation of its two symbolic operands, which are character
   1.911 +strings.
   1.912 +
   1.913 +\subsubsection{Hierarchy of operations}
   1.914 +
   1.915 +The following list shows the hierarchy of operations in symbolic
   1.916 +expressions:
   1.917 +
   1.918 +\medskip
   1.919 +
   1.920 +\noindent\hfil
   1.921 +\begin{tabular}{@{}ll@{}}
   1.922 +Operation&Hierarchy\\
   1.923 +\hline
   1.924 +Evaluation of numeric operations&1st-7th\\
   1.925 +Concatenation ({\tt\&})&8th\\
   1.926 +Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
   1.927 +7th\\
   1.928 +\end{tabular}
   1.929 +
   1.930 +\medskip
   1.931 +
   1.932 +This hierarchy has the same meaning as was explained above for numeric
   1.933 +expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
   1.934 +
   1.935 +\subsection{Indexing expressions and dummy indices}
   1.936 +\label{indexing}
   1.937 +
   1.938 +An {\it indexing expression} is an auxiliary construction, which
   1.939 +specifies a plain set of $n$-tuples and introduces dummy indices. It
   1.940 +has two syntactic forms:
   1.941 +
   1.942 +\medskip
   1.943 +
   1.944 +\noindent\hspace{73.5pt}
   1.945 +{\tt\{} {\it entry}$_1${\tt,} {\it entry}$_2${\tt,} \dots{\tt,}
   1.946 +{\it entry}$_m$ {\tt\}}
   1.947 +
   1.948 +\medskip
   1.949 +
   1.950 +\noindent\hfil
   1.951 +{\tt\{} {\it entry}$_1${\tt,} {\it entry}$_2${\tt,} \dots{\tt,}
   1.952 +{\it entry}$_m$ {\tt:} {\it predicate} {\tt\}}
   1.953 +
   1.954 +\medskip
   1.955 +
   1.956 +\noindent where {\it entry}{$_1$}, {\it entry}{$_2$}, \dots,
   1.957 +{\it entry}{$_m$} are indexing entries, {\it predicate} is a logical
   1.958 +expression that specifies an optional predicate (logical condition).
   1.959 +
   1.960 +Each {\it indexing entry} in the indexing expression has one of the
   1.961 +following three forms:
   1.962 +
   1.963 +\medskip
   1.964 +
   1.965 +\noindent\hspace{123pt}
   1.966 +$i$ {\tt in} $S$
   1.967 +
   1.968 +\medskip
   1.969 +
   1.970 +\noindent\hfil
   1.971 +{\tt(}$i_1${\tt,} $i_2${\tt,} \dots{\tt,}$i_n${\tt)} {\tt in} $S$
   1.972 +
   1.973 +\medskip
   1.974 +
   1.975 +\noindent\hspace{123pt}
   1.976 +$S$
   1.977 +
   1.978 +\medskip
   1.979 +
   1.980 +\noindent where $i_1$, $i_2$, \dots, $i_n$ are indices, $S$ is a set
   1.981 +expression (discussed in the next section) that specifies the basic set.
   1.982 +
   1.983 +The number of indices in the indexing entry must be the same as the
   1.984 +dimension of the basic set $S$, i.e. if $S$ consists of 1-tuples, the
   1.985 +first form must be used, and if $S$ consists of $n$-tuples, where
   1.986 +$n>1$, the second form must be used.
   1.987 +
   1.988 +If the first form of the indexing entry is used, the index $i$ can be
   1.989 +a dummy index only (see below). If the second form is used, the indices
   1.990 +$i_1$, $i_2$, \dots, $i_n$ can be either dummy indices or some numeric
   1.991 +or symbolic expressions, where at least one index must be a dummy index.
   1.992 +The third, reduced form of the indexing entry has the same effect as if
   1.993 +there were $i$ (if $S$ is 1-dimensional) or $i_1$, $i_2$, \dots, $i_n$
   1.994 +(if $S$ is $n$-dimensional) all specified as dummy indices.
   1.995 +
   1.996 +A {\it dummy index} is an auxiliary model object, which acts like an
   1.997 +individual variable. Values assigned to dummy indices are components of
   1.998 +$n$-tuples from basic sets, i.e. some numeric and symbolic quantities.
   1.999 +
  1.1000 +For referencing purposes dummy indices can be provided with symbolic
  1.1001 +names. However, unlike other model objects (sets, parameters, etc.)
  1.1002 +dummy indices need not be explicitly declared. Each {\it undeclared}
  1.1003 +symbolic name being used in the indexing position of an indexing entry
  1.1004 +is recognized as the symbolic name of corresponding dummy index.
  1.1005 +
  1.1006 +Symbolic names of dummy indices are valid only within the scope of the
  1.1007 +indexing expression, where the dummy indices were introduced. Beyond
  1.1008 +the scope the dummy indices are completely inaccessible, so the same
  1.1009 +symbolic names may be used for other purposes, in particular, to
  1.1010 +represent dummy indices in other indexing expressions.
  1.1011 +
  1.1012 +The scope of indexing expression, where implicit declarations of dummy
  1.1013 +indices are valid, depends on the context, in which the indexing
  1.1014 +expression is used:
  1.1015 +
  1.1016 +\begin{enumerate}
  1.1017 +\item If the indexing expression is used in iterated operator, its
  1.1018 +scope extends until the end of the integrand.
  1.1019 +\item If the indexing expression is used as a primary set expression,
  1.1020 +its scope extends until the end of that indexing expression.
  1.1021 +\item If the indexing expression is used to define the subscript domain
  1.1022 +in declarations of some model objects, its scope extends until the end
  1.1023 +of the corresponding statement.
  1.1024 +\end{enumerate}
  1.1025 +
  1.1026 +The indexing mechanism implemented by means of indexing expressions is
  1.1027 +best explained by some examples discussed below.
  1.1028 +
  1.1029 +Let there be given three sets:
  1.1030 +
  1.1031 +\medskip
  1.1032 +
  1.1033 +\noindent\hspace{33.5pt}
  1.1034 +$A=\{4,7,9\}$,
  1.1035 +
  1.1036 +\medskip
  1.1037 +
  1.1038 +\noindent\hfil
  1.1039 +$B=\{(1,Jan),(1,Feb),(2,Mar),(2,Apr),(3,May),(3,Jun)\}$,
  1.1040 +
  1.1041 +\medskip
  1.1042 +
  1.1043 +\noindent\hspace{33.5pt}
  1.1044 +$C=\{a,b,c\}$,
  1.1045 +
  1.1046 +\medskip
  1.1047 +
  1.1048 +\noindent where $A$ and $C$ consist of 1-tuples (singlets), $B$
  1.1049 +consists of 2-tuples (doublets). Consider the following indexing
  1.1050 +expression:
  1.1051 +
  1.1052 +\medskip
  1.1053 +
  1.1054 +\noindent\hfil
  1.1055 +{\tt\{i in A, (j,k) in B, l in C\}}
  1.1056 +
  1.1057 +\medskip
  1.1058 +
  1.1059 +\noindent where {\tt i}, {\tt j}, {\tt k}, and {\tt l} are dummy
  1.1060 +indices.
  1.1061 +
  1.1062 +Although MathProg is not a procedural language, for any indexing
  1.1063 +expression an equivalent algorithmic description can be given. In
  1.1064 +particular, the algorithmic description of the indexing expression
  1.1065 +above could look like follows:
  1.1066 +
  1.1067 +\medskip
  1.1068 +
  1.1069 +\noindent\hfil
  1.1070 +\begin{tabular}{@{}l@{}}
  1.1071 +{\bf for all} $i\in A$ {\bf do}\\
  1.1072 +\hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf do}\\
  1.1073 +\hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
  1.1074 +\hspace{36pt}{\it action};\\
  1.1075 +\end{tabular}
  1.1076 +
  1.1077 +\newpage
  1.1078 +
  1.1079 +\noindent where the dummy indices $i$, $j$, $k$, $l$ are consecutively
  1.1080 +assigned corresponding components of $n$-tuples from the basic sets $A$,
  1.1081 +$B$, $C$, and {\it action} is some action that depends on the context,
  1.1082 +where the indexing expression is used. For example, if the action were
  1.1083 +printing current values of dummy indices, the printout would look like
  1.1084 +follows:
  1.1085 +
  1.1086 +\medskip
  1.1087 +
  1.1088 +\noindent\hfil
  1.1089 +\begin{tabular}{@{}llll@{}}
  1.1090 +$i=4$&$j=1$&$k=Jan$&$l=a$\\
  1.1091 +$i=4$&$j=1$&$k=Jan$&$l=b$\\
  1.1092 +$i=4$&$j=1$&$k=Jan$&$l=c$\\
  1.1093 +$i=4$&$j=1$&$k=Feb$&$l=a$\\
  1.1094 +$i=4$&$j=1$&$k=Feb$&$l=b$\\
  1.1095 +\multicolumn{4}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  1.1096 +$i=9$&$j=3$&$k=Jun$&$l=b$\\
  1.1097 +$i=9$&$j=3$&$k=Jun$&$l=c$\\
  1.1098 +\end{tabular}
  1.1099 +
  1.1100 +\medskip
  1.1101 +
  1.1102 +Let the example indexing expression be used in the following iterated
  1.1103 +operation:
  1.1104 +
  1.1105 +\medskip
  1.1106 +
  1.1107 +\noindent\hfil
  1.1108 +{\tt sum\{i in A, (j,k) in B, l in C\} p[i,j,k,l]}
  1.1109 +
  1.1110 +\medskip
  1.1111 +
  1.1112 +\noindent where {\tt p} is a 4-dimensional numeric parameter or some
  1.1113 +numeric expression whose resultant value depends on {\tt i}, {\tt j},
  1.1114 +{\tt k}, and {\tt l}. In this case the action is summation, so the
  1.1115 +resultant value of the primary numeric expression is:
  1.1116 +$$\sum_{i\in A,(j,k)\in B,l\in C}(p_{ijkl}).$$
  1.1117 +
  1.1118 +Now let the example indexing expression be used as a primary set
  1.1119 +expression. In this case the action is gathering all 4-tuples
  1.1120 +(quadruplets) of the form $(i,j,k,l)$ in one set, so the resultant
  1.1121 +value of such operation is simply the Cartesian product of the basic
  1.1122 +sets:
  1.1123 +$$A\times B\times C=\{(i,j,k,l):i\in A,(j,k)\in B,l\in C\}.$$
  1.1124 +Note that in this case the same indexing expression might be written in
  1.1125 +the reduced form:
  1.1126 +
  1.1127 +\medskip
  1.1128 +
  1.1129 +\noindent\hfil
  1.1130 +{\tt\{A, B, C\}}
  1.1131 +
  1.1132 +\medskip
  1.1133 +
  1.1134 +\noindent because the dummy indices $i$, $j$, $k$, and $l$ are not
  1.1135 +referenced and therefore their symbolic names need not be specified.
  1.1136 +
  1.1137 +Finally, let the example indexing expression be used as the subscript
  1.1138 +domain in the declaration of a 4-dimensional model object, say,
  1.1139 +a numeric parameter:
  1.1140 +
  1.1141 +\medskip
  1.1142 +
  1.1143 +\noindent\hfil
  1.1144 +{\tt param p\{i in A, (j,k) in B, l in C\}} \dots {\tt;}
  1.1145 +
  1.1146 +\medskip
  1.1147 +
  1.1148 +\noindent In this case the action is generating the parameter members,
  1.1149 +where each member has the form $p[i,j,k,l]$.
  1.1150 +
  1.1151 +As was said above, some indices in the second form of indexing entries
  1.1152 +may be numeric or symbolic expressions, not only dummy indices. In this
  1.1153 +case resultant values of such expressions play role of some logical
  1.1154 +conditions to select only that $n$-tuples from the Cartesian product of
  1.1155 +basic sets that satisfy these conditions.
  1.1156 +
  1.1157 +Consider, for example, the following indexing expression:
  1.1158 +
  1.1159 +\medskip
  1.1160 +
  1.1161 +\noindent\hfil
  1.1162 +{\tt\{i in A, (i-1,k) in B, l in C\}}
  1.1163 +
  1.1164 +\medskip
  1.1165 +
  1.1166 +\noindent where {\tt i}, {\tt k}, {\tt l} are dummy indices, and
  1.1167 +{\tt i-1} is a numeric expression. The algorithmic decsription of this
  1.1168 +indexing expression is the following:
  1.1169 +
  1.1170 +\medskip
  1.1171 +
  1.1172 +\noindent\hfil
  1.1173 +\begin{tabular}{@{}l@{}}
  1.1174 +{\bf for all} $i\in A$ {\bf do}\\
  1.1175 +\hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf and} $j=i-1$ {\bf do}\\
  1.1176 +\hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
  1.1177 +\hspace{36pt}{\it action};\\
  1.1178 +\end{tabular}
  1.1179 +
  1.1180 +\medskip
  1.1181 +
  1.1182 +\noindent Thus, if this indexing expression were used as a primary set
  1.1183 +expression, the resultant set would be the following:
  1.1184 +$$\{(4,May,a),(4,May,b),(4,May,c),(4,Jun,a),(4,Jun,b),(4,Jun,c)\}.$$
  1.1185 +Should note that in this case the resultant set consists of 3-tuples,
  1.1186 +not of 4-tuples, because in the indexing expression there is no dummy
  1.1187 +index that corresponds to the first component of 2-tuples from the set
  1.1188 +$B$.
  1.1189 +
  1.1190 +The general rule is: the number of components of $n$-tuples defined by
  1.1191 +an indexing expression is the same as the number of dummy indices in
  1.1192 +that expression, where the correspondence between dummy indices and
  1.1193 +components on $n$-tuples in the resultant set is positional, i.e. the
  1.1194 +first dummy index corresponds to the first component, the second dummy
  1.1195 +index corresponds to the second component, etc.
  1.1196 +
  1.1197 +In some cases it is needed to select a subset from the Cartesian
  1.1198 +product of some sets. This may be attained by using an optional logical
  1.1199 +predicate, which is specified in the indexing expression.
  1.1200 +
  1.1201 +Consider, for example, the following indexing expression:
  1.1202 +
  1.1203 +\medskip
  1.1204 +
  1.1205 +\noindent\hfil
  1.1206 +{\tt\{i in A, (j,k) in B, l in C: i <= 5 and k <> 'Mar'\}}
  1.1207 +
  1.1208 +\medskip
  1.1209 +
  1.1210 +\noindent where the logical expression following the colon is a
  1.1211 +predicate. The algorithmic description of this indexing expression is
  1.1212 +the following:
  1.1213 +
  1.1214 +\medskip
  1.1215 +
  1.1216 +\noindent\hfil
  1.1217 +\begin{tabular}{@{}l@{}}
  1.1218 +{\bf for all} $i\in A$ {\bf do}\\
  1.1219 +\hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf do}\\
  1.1220 +\hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
  1.1221 +\hspace{36pt}{\bf if} $i\leq 5$ {\bf and} $l\neq`Mar'$ {\bf then}\\
  1.1222 +\hspace{48pt}{\it action};\\
  1.1223 +\end{tabular}
  1.1224 +
  1.1225 +\medskip
  1.1226 +
  1.1227 +\noindent Thus, if this indexing expression were used as a primary set
  1.1228 +expression, the resultant set would be the following:
  1.1229 +$$\{(4,1,Jan,a),(4,1,Feb,a),(4,2,Apr,a),\dots,(4,3,Jun,c)\}.$$
  1.1230 +
  1.1231 +If no predicate is specified in the indexing expression, one, which
  1.1232 +takes on the value {\it true}, is assumed.
  1.1233 +
  1.1234 +\subsection{Set expressions}
  1.1235 +
  1.1236 +A {\it set expression} is a rule for computing an elemental set, i.e.
  1.1237 +a collection of $n$-tuples, where components of $n$-tuples are numeric
  1.1238 +and symbolic quantities.
  1.1239 +
  1.1240 +The primary set expression may be a literal set, unsubscripted set,
  1.1241 +subscripted set, ``arithmetic'' set, indexing expression, iterated set
  1.1242 +expression, conditional set expression, or another set expression
  1.1243 +enclosed in parentheses.
  1.1244 +
  1.1245 +\medskip
  1.1246 +
  1.1247 +\noindent{\bf Examples}
  1.1248 +
  1.1249 +\medskip
  1.1250 +
  1.1251 +\noindent
  1.1252 +\begin{tabular}{@{}ll@{}}
  1.1253 +\verb|{(123,'aa'), (i,'bb'), (j-1,'cc')}|&(literal set)\\
  1.1254 +\verb|I|&(unsubscripted set)\\
  1.1255 +\verb|S[i-1,j+1]|&(subscripted set)\\
  1.1256 +\verb|1..t-1 by 2|&(``arithmetic'' set)\\
  1.1257 +\verb|{t in 1..T, (t+1,j) in S: (t,j) in F}|&(indexing expression)\\
  1.1258 +\verb|setof{i in I, j in J}(i+1,j-1)|&(iterated expression)\\
  1.1259 +\verb|if i < j then S[i] else F diff S[j]|&(conditional expression)\\
  1.1260 +\verb|(1..10 union 21..30)|&(parenthesized expression)\\
  1.1261 +\end{tabular}
  1.1262 +
  1.1263 +\medskip
  1.1264 +
  1.1265 +More general set expressions containing two or more primary set
  1.1266 +expressions may be constructed by using certain set operators.
  1.1267 +
  1.1268 +\medskip
  1.1269 +
  1.1270 +\noindent{\bf Examples}
  1.1271 +
  1.1272 +\medskip
  1.1273 +
  1.1274 +\noindent\verb|(A union B) inter (I cross J)|
  1.1275 +
  1.1276 +\noindent
  1.1277 +\verb|1..10 cross (if i < j then {'a', 'b', 'c'} else {'d', 'e', 'f'})|
  1.1278 +
  1.1279 +\subsubsection{Literal sets}
  1.1280 +
  1.1281 +A {\it literal set} is a primary set expression, which has the
  1.1282 +following two syntactic forms:
  1.1283 +
  1.1284 +\medskip
  1.1285 +
  1.1286 +\noindent\hspace{39pt}
  1.1287 +{\tt\{}$e_1${\tt,} $e_2${\tt,} \dots{\tt,} $e_m${\tt\}}
  1.1288 +
  1.1289 +\medskip
  1.1290 +
  1.1291 +\noindent\hfil
  1.1292 +{\tt\{(}$e_{11}${\tt,} \dots{\tt,} $e_{1n}${\tt),}
  1.1293 +{\tt(}$e_{21}${\tt,} \dots{\tt,} $e_{2n}${\tt),} \dots{\tt,}
  1.1294 +{\tt(}$e_{m1}${\tt,} \dots{\tt,} $e_{mn}${\tt)\}}
  1.1295 +
  1.1296 +\medskip
  1.1297 +
  1.1298 +\noindent where $e_1$, \dots, $e_m$, $e_{11}$, \dots, $e_{mn}$ are
  1.1299 +numeric or symbolic expressions.
  1.1300 +
  1.1301 +If the first form is used, the resultant set consists of 1-tuples
  1.1302 +(singlets) enumerated within the curly braces. It is allowed to specify
  1.1303 +an empty set as {\tt\{\ \}}, which has no 1-tuples. If the second form
  1.1304 +is used, the resultant set consists of $n$-tuples enumerated within the
  1.1305 +curly braces, where a particular $n$-tuple consists of corresponding
  1.1306 +components enumerated within the parentheses. All $n$-tuples must have
  1.1307 +the same number of components.
  1.1308 +
  1.1309 +\subsubsection{Unsubscripted sets}
  1.1310 +
  1.1311 +If the primary set expression is an unsubscripted set (which must be
  1.1312 +0-dimen\-sional), the resultant set is an elemental set associated with
  1.1313 +the corresponding set object.
  1.1314 +
  1.1315 +\newpage
  1.1316 +
  1.1317 +\subsubsection{Subscripted sets}
  1.1318 +
  1.1319 +The primary set expression, which refers to a subscripted set, has the
  1.1320 +following syntactic form:
  1.1321 +
  1.1322 +\medskip
  1.1323 +
  1.1324 +\noindent\hfil
  1.1325 +{\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
  1.1326 +
  1.1327 +\medskip
  1.1328 +
  1.1329 +\noindent where {\it name} is the symbolic name of the set object,
  1.1330 +$i_1$, $i_2$, \dots, $i_n$ are subscripts.
  1.1331 +
  1.1332 +Each subscript must be a numeric or symbolic expression. The number of
  1.1333 +subscripts in the subscript list must be the same as the dimension of
  1.1334 +the set object with which the subscript list is associated.
  1.1335 +
  1.1336 +Actual values of subscript expressions are used to identify a
  1.1337 +particular member of the set object that determines the resultant set.
  1.1338 +
  1.1339 +\subsubsection{``Arithmetic'' sets}
  1.1340 +
  1.1341 +The primary set expression, which is an ``arithmetic'' set, has the
  1.1342 +following two syntactic forms:
  1.1343 +
  1.1344 +\medskip
  1.1345 +
  1.1346 +\noindent\hfil
  1.1347 +$t_0$ {\tt..} $t_1$ {\tt by} $\delta t$
  1.1348 +
  1.1349 +\medskip
  1.1350 +
  1.1351 +\noindent\hspace{138.5pt}
  1.1352 +$t_0$ {\tt..} $t_1$
  1.1353 +
  1.1354 +\medskip
  1.1355 +
  1.1356 +\noindent where $t_0$, $t_1$, and $\delta t$ are numeric expressions
  1.1357 +(the value of $\delta t$ must not be zero). The second form is
  1.1358 +equivalent to the first form, where $\delta t=1$.
  1.1359 +
  1.1360 +If $\delta t>0$, the resultant set is determined as follows:
  1.1361 +$$\{t:\exists k\in{\cal Z}(t=t_0+k\delta t,\ t_0\leq t\leq t_1)\}.$$
  1.1362 +Otherwise, if $\delta t<0$, the resultant set is determined as follows:
  1.1363 +$$\{t:\exists k\in{\cal Z}(t=t_0+k\delta t,\ t_1\leq t\leq t_0)\}.$$
  1.1364 +
  1.1365 +\subsubsection{Indexing expressions}
  1.1366 +
  1.1367 +If the primary set expression is an indexing expression, the resultant
  1.1368 +set is determined as described above in Subsection \ref{indexing}, page
  1.1369 +\pageref{indexing}.
  1.1370 +
  1.1371 +\subsubsection{Iterated expressions}
  1.1372 +
  1.1373 +An {\it iterated set expression} is a primary set expression, which has
  1.1374 +the following syntactic form:
  1.1375 +
  1.1376 +\medskip
  1.1377 +
  1.1378 +\noindent\hfil
  1.1379 +{\tt setof} {\it indexing-expression} {\it integrand}
  1.1380 +
  1.1381 +\medskip
  1.1382 +
  1.1383 +\noindent where {\it indexing-expression} is an indexing expression,
  1.1384 +which introduces dummy indices and controls iterating, {\it integrand}
  1.1385 +is either a single numeric or symbolic expression or a list of numeric
  1.1386 +and symbolic expressions separated by commae and enclosed in
  1.1387 +parentheses.
  1.1388 +
  1.1389 +If the integrand is a single numeric or symbolic expression, the
  1.1390 +resultant set consists of 1-tuples and is determined as follows:
  1.1391 +$$\{x:(i_1,\dots,i_n)\in\Delta\},$$
  1.1392 +\noindent where $x$ is a value of the integrand, $i_1$, \dots, $i_n$
  1.1393 +are dummy indices introduced in the indexing expression, $\Delta$ is
  1.1394 +the domain, a set of $n$-tuples specified by the indexing expression,
  1.1395 +which defines particular values assigned to the dummy indices on
  1.1396 +performing the iterated operation.
  1.1397 +
  1.1398 +If the integrand is a list containing $m$ numeric and symbolic
  1.1399 +expressions, the resultant set consists of $m$-tuples and is determined
  1.1400 +as follows:
  1.1401 +$$\{(x_1,\dots,x_m):(i_1,\dots,i_n)\in\Delta\},$$
  1.1402 +where $x_1$, \dots, $x_m$ are values of the expressions in the
  1.1403 +integrand list, $i_1$, \dots, $i_n$ and $\Delta$ have the same meaning
  1.1404 +as above.
  1.1405 +
  1.1406 +\subsubsection{Conditional expressions}
  1.1407 +
  1.1408 +A {\it conditional set expression} is a primary set expression that has
  1.1409 +the following syntactic form:
  1.1410 +
  1.1411 +\medskip
  1.1412 +
  1.1413 +\noindent\hfil
  1.1414 +{\tt if} $b$ {\tt then} $X$ {\tt else} $Y$
  1.1415 +
  1.1416 +\medskip
  1.1417 +
  1.1418 +\noindent where $b$ is an logical expression, $X$ and $Y$ are set
  1.1419 +expressions, which must define sets of the same dimension.
  1.1420 +
  1.1421 +The resultant value of the conditional expression depends on the value
  1.1422 +of the logical expression that follows the keyword {\tt if}. If it
  1.1423 +takes on the value {\it true}, the resultant set is the value of the
  1.1424 +expression that follows the keyword {\tt then}. Otherwise, if the
  1.1425 +logical expression takes on the value {\it false}, the resultant set is
  1.1426 +the value of the expression that follows the keyword {\tt else}.
  1.1427 +
  1.1428 +\subsubsection{Parenthesized expressions}
  1.1429 +
  1.1430 +Any set expression may be enclosed in parentheses that syntactically
  1.1431 +makes it a primary set expression.
  1.1432 +
  1.1433 +Parentheses may be used in set expressions, as in algebra, to specify
  1.1434 +the desired order in which operations are to be performed. Where
  1.1435 +parentheses are used, the expression within the parentheses is
  1.1436 +evaluated before the resultant value is used.
  1.1437 +
  1.1438 +The resultant value of the parenthesized expression is the same as the
  1.1439 +value of the expression enclosed within parentheses.
  1.1440 +
  1.1441 +\subsubsection{Set operators}
  1.1442 +
  1.1443 +In MathProg there exist the following set operators, which may be used
  1.1444 +in set expressions:
  1.1445 +
  1.1446 +\medskip
  1.1447 +
  1.1448 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  1.1449 +$X$ {\tt union} $Y$&union $X\cup Y$\\
  1.1450 +$X$ {\tt diff} $Y$&difference $X\backslash Y$\\
  1.1451 +$X$ {\tt symdiff} $Y$&symmetric difference $X\oplus Y$\\
  1.1452 +$X$ {\tt inter} $Y$&intersection $X\cap Y$\\
  1.1453 +$X$ {\tt cross} $Y$&cross (Cartesian) product $X\times Y$\\
  1.1454 +\end{tabular}
  1.1455 +
  1.1456 +\medskip
  1.1457 +
  1.1458 +\noindent where $X$ and Y are set expressions, which must define sets
  1.1459 +of the identical dimension (except the Cartesian product).
  1.1460 +
  1.1461 +If the expression includes more than one set operator, all operators
  1.1462 +are performed from left to right according to the hierarchy of
  1.1463 +operations (see below).
  1.1464 +
  1.1465 +The resultant value of the expression, which contains set operators, is
  1.1466 +the result of applying the operators to their operands.
  1.1467 +
  1.1468 +The dimension of the resultant set, i.e. the dimension of $n$-tuples,
  1.1469 +of which the resultant set consists of, is the same as the dimension of
  1.1470 +the operands, except the Cartesian product, where the dimension of the
  1.1471 +resultant set is the sum of the dimensions of its operands.
  1.1472 +
  1.1473 +\subsubsection{Hierarchy of operations}
  1.1474 +
  1.1475 +The following list shows the hierarchy of operations in set
  1.1476 +expressions:
  1.1477 +
  1.1478 +\medskip
  1.1479 +
  1.1480 +\noindent\hfil
  1.1481 +\begin{tabular}{@{}ll@{}}
  1.1482 +Operation&Hierarchy\\
  1.1483 +\hline
  1.1484 +Evaluation of numeric operations&1st-7th\\
  1.1485 +Evaluation of symbolic operations&8th-9th\\
  1.1486 +Evaluation of iterated or ``arithmetic'' set ({\tt setof}, {\tt..})&
  1.1487 +10th\\
  1.1488 +Cartesian product ({\tt cross})&11th\\
  1.1489 +Intersection ({\tt inter})&12th\\
  1.1490 +Union and difference ({\tt union}, {\tt diff}, {\tt symdiff})&13th\\
  1.1491 +Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
  1.1492 +14th\\
  1.1493 +\end{tabular}
  1.1494 +
  1.1495 +\medskip
  1.1496 +
  1.1497 +This hierarchy has the same meaning as was explained above for numeric
  1.1498 +expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
  1.1499 +
  1.1500 +\subsection{Logical expressions}
  1.1501 +
  1.1502 +A {\it logical expression} is a rule for computing a single logical
  1.1503 +value, which can be either {\it true} or {\it false}.
  1.1504 +
  1.1505 +The primary logical expression may be a numeric expression, relational
  1.1506 +expression, iterated logical expression, or another logical expression
  1.1507 +enclosed in parentheses.
  1.1508 +
  1.1509 +\medskip
  1.1510 +
  1.1511 +\noindent{\bf Examples}
  1.1512 +
  1.1513 +\medskip
  1.1514 +
  1.1515 +\noindent
  1.1516 +\begin{tabular}{@{}ll@{}}
  1.1517 +\verb|i+1|&(numeric expression)\\
  1.1518 +\verb|a[i,j] < 1.5|&(relational expression)\\
  1.1519 +\verb|s[i+1,j-1] <> 'Mar'|&(relational expression)\\
  1.1520 +\verb|(i+1,'Jan') not in I cross J|&(relational expression)\\
  1.1521 +\verb|S union T within A[i] inter B[j]|&(relational expression)\\
  1.1522 +\verb|forall{i in I, j in J} a[i,j] < .5 * b|&(iterated expression)\\
  1.1523 +\verb|(a[i,j] < 1.5 or b[i] >= a[i,j])|&(parenthesized expression)\\
  1.1524 +\end{tabular}
  1.1525 +
  1.1526 +\medskip
  1.1527 +
  1.1528 +More general logical expressions containing two or more primary logical
  1.1529 +expressions may be constructed by using certain logical operators.
  1.1530 +
  1.1531 +\newpage
  1.1532 +
  1.1533 +\noindent{\bf Examples}
  1.1534 +
  1.1535 +\medskip
  1.1536 +
  1.1537 +\noindent\verb|not (a[i,j] < 1.5 or b[i] >= a[i,j]) and (i,j) in S|
  1.1538 +
  1.1539 +\noindent\verb|(i,j) in S or (i,j) not in T diff U|
  1.1540 +
  1.1541 +\subsubsection{Numeric expressions}
  1.1542 +
  1.1543 +The resultant value of the primary logical expression, which is a
  1.1544 +numeric expression, is {\it true}, if the resultant value of the
  1.1545 +numeric expression is non-zero. Otherwise the resultant value of the
  1.1546 +logical expression is {\it false}.
  1.1547 +
  1.1548 +\subsubsection{Relational operators}
  1.1549 +
  1.1550 +In MathProg there exist the following relational operators, which may
  1.1551 +be used in logical expressions:
  1.1552 +
  1.1553 +\medskip
  1.1554 +
  1.1555 +\begin{tabular}{@{}ll@{}}
  1.1556 +$x$ {\tt<} $y$&test on $x<y$\\
  1.1557 +$x$ {\tt<=} $y$&test on $x\leq y$\\
  1.1558 +$x$ {\tt=} $y$, $x$ {\tt==} $y$&test on $x=y$\\
  1.1559 +$x$ {\tt>=} $y$&test on $x\geq y$\\
  1.1560 +$x$ {\tt>} $y$&test on $x>y$\\
  1.1561 +$x$ {\tt<>} $y$, $x$ {\tt!=} $y$&test on $x\neq y$\\
  1.1562 +$x$ {\tt in} $Y$&test on $x\in Y$\\
  1.1563 +{\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt in} $Y$&test on
  1.1564 +$(x_1,\dots,x_n)\in Y$\\
  1.1565 +$x$ {\tt not} {\tt in} $Y$, $x$ {\tt!in} $Y$&test on $x\not\in Y$\\
  1.1566 +{\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt not} {\tt in} $Y$,
  1.1567 +{\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt !in} $Y$&test on
  1.1568 +$(x_1,\dots,x_n)\not\in Y$\\
  1.1569 +$X$ {\tt within} $Y$&test on $X\subseteq Y$\\
  1.1570 +$X$ {\tt not} {\tt within} $Y$, $X$ {\tt !within} $Y$&test on
  1.1571 +$X\not\subseteq Y$\\
  1.1572 +\end{tabular}
  1.1573 +
  1.1574 +\medskip
  1.1575 +
  1.1576 +\noindent where $x$, $x_1$, \dots, $x_n$, $y$ are numeric or symbolic
  1.1577 +expressions, $X$ and $Y$ are set expression.
  1.1578 +
  1.1579 +{\it Notes:}
  1.1580 +
  1.1581 +1. In the operations {\tt in}, {\tt not in}, and {\tt !in} the
  1.1582 +number of components in the first operands must be the same as the
  1.1583 +dimension of the second operand.
  1.1584 +
  1.1585 +2. In the operations {\tt within}, {\tt not within}, and {\tt !within}
  1.1586 +both operands must have identical dimension.
  1.1587 +
  1.1588 +All the relational operators listed above have their conventional
  1.1589 +mathematical meaning. The resultant value is {\it true}, if
  1.1590 +corresponding relation is satisfied for its operands, otherwise
  1.1591 +{\it false}. (Note that symbolic values are ordered lexicographically,
  1.1592 +and any numeric value precedes any symbolic value.)
  1.1593 +
  1.1594 +\subsubsection{Iterated expressions}
  1.1595 +
  1.1596 +An {\it iterated logical expression} is a primary logical expression,
  1.1597 +which has the following syntactic form:
  1.1598 +
  1.1599 +\medskip
  1.1600 +
  1.1601 +\noindent\hfil
  1.1602 +{\it iterated-operator} {\it indexing-expression} {\it integrand}
  1.1603 +
  1.1604 +\medskip
  1.1605 +
  1.1606 +\noindent where {\it iterated-operator} is the symbolic name of the
  1.1607 +iterated operator to be performed (see below), {\it indexing-expression}
  1.1608 +is an indexing expression which introduces dummy indices and controls
  1.1609 +iterating, {\it integrand} is a numeric expression that participates in
  1.1610 +the operation.
  1.1611 +
  1.1612 +In MathProg there exist two iterated operators, which may be used in
  1.1613 +logical expressions:
  1.1614 +
  1.1615 +\medskip
  1.1616 +
  1.1617 +\noindent\hfil
  1.1618 +\begin{tabular}{@{}lll@{}}
  1.1619 +{\tt forall}&$\forall$-quantification&$\displaystyle
  1.1620 +\forall(i_1,\dots,i_n)\in\Delta[f(i_1,\dots,i_n)],$\\
  1.1621 +{\tt exists}&$\exists$-quantification&$\displaystyle
  1.1622 +\exists(i_1,\dots,i_n)\in\Delta[f(i_1,\dots,i_n)],$\\
  1.1623 +\end{tabular}
  1.1624 +
  1.1625 +\medskip
  1.1626 +
  1.1627 +\noindent where $i_1$, \dots, $i_n$ are dummy indices introduced in
  1.1628 +the indexing expression, $\Delta$ is the domain, a set of $n$-tuples
  1.1629 +specified by the indexing expression which defines particular values
  1.1630 +assigned to the dummy indices on performing the iterated operation,
  1.1631 +$f(i_1,\dots,i_n)$ is the integrand, a logical expression whose
  1.1632 +resultant value depends on the dummy indices.
  1.1633 +
  1.1634 +For $\forall$-quantification the resultant value of the iterated
  1.1635 +logical expression is {\it true}, if the value of the integrand is
  1.1636 +{\it true} for all $n$-tuples contained in the domain, otherwise
  1.1637 +{\it false}.
  1.1638 +
  1.1639 +For $\exists$-quantification the resultant value of the iterated
  1.1640 +logical expression is {\it false}, if the value of the integrand is
  1.1641 +{\it false} for all $n$-tuples contained in the domain, otherwise
  1.1642 +{\it true}.
  1.1643 +
  1.1644 +\subsubsection{Parenthesized expressions}
  1.1645 +
  1.1646 +Any logical expression may be enclosed in parentheses that
  1.1647 +syntactically makes it a primary logical expression.
  1.1648 +
  1.1649 +Parentheses may be used in logical expressions, as in algebra, to
  1.1650 +specify the desired order in which operations are to be performed.
  1.1651 +Where parentheses are used, the expression within the parentheses is
  1.1652 +evaluated before the resultant value is used.
  1.1653 +
  1.1654 +The resultant value of the parenthesized expression is the same as the
  1.1655 +value of the expression enclosed within parentheses.
  1.1656 +
  1.1657 +\subsubsection{Logical operators}
  1.1658 +
  1.1659 +In MathProg there exist the following logical operators, which may be
  1.1660 +used in logical expressions:
  1.1661 +
  1.1662 +\medskip
  1.1663 +
  1.1664 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  1.1665 +{\tt not} $x$, {\tt!}$x$&negation $\neg\ x$\\
  1.1666 +$x$ {\tt and} $y$, $x$ {\tt\&\&} $y$&conjunction (logical ``and'')
  1.1667 +$x\;\&\;y$\\
  1.1668 +$x$ {\tt or} $y$, $x$ {\tt||} $y$&disjunction (logical ``or'')
  1.1669 +$x\vee y$\\
  1.1670 +\end{tabular}
  1.1671 +
  1.1672 +\medskip
  1.1673 +
  1.1674 +\noindent where $x$ and $y$ are logical expressions.
  1.1675 +
  1.1676 +If the expression includes more than one logical operator, all
  1.1677 +operators are performed from left to right according to the hierarchy
  1.1678 +of the operations (see below). The resultant value of the expression,
  1.1679 +which contains logical operators, is the result of applying the
  1.1680 +operators to their operands.
  1.1681 +
  1.1682 +\subsubsection{Hierarchy of operations}
  1.1683 +
  1.1684 +The following list shows the hierarchy of operations in logical
  1.1685 +expressions:
  1.1686 +
  1.1687 +\medskip
  1.1688 +
  1.1689 +\noindent\hfil
  1.1690 +\begin{tabular}{@{}ll@{}}
  1.1691 +Operation&Hierarchy\\
  1.1692 +\hline
  1.1693 +Evaluation of numeric operations&1st-7th\\
  1.1694 +Evaluation of symbolic operations&8th-9th\\
  1.1695 +Evaluation of set operations&10th-14th\\
  1.1696 +Relational operations ({\tt<}, {\tt<=}, etc.)&15th\\
  1.1697 +Negation ({\tt not}, {\tt!})&16th\\
  1.1698 +Conjunction ({\tt and}, {\tt\&\&})&17th\\
  1.1699 +$\forall$- and $\exists$-quantification ({\tt forall}, {\tt exists})&
  1.1700 +18th\\
  1.1701 +Disjunction ({\tt or}, {\tt||})&19th\\
  1.1702 +\end{tabular}
  1.1703 +
  1.1704 +\medskip
  1.1705 +
  1.1706 +This hierarchy has the same meaning as was explained above for numeric
  1.1707 +expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
  1.1708 +
  1.1709 +\subsection{Linear expressions}
  1.1710 +
  1.1711 +An {\it linear expression} is a rule for computing so called
  1.1712 +a {\it linear form} or simply a {\it formula}, which is a linear (or
  1.1713 +affine) function of elemental variables.
  1.1714 +
  1.1715 +The primary linear expression may be an unsubscripted variable,
  1.1716 +subscripted variable, iterated linear expression, conditional linear
  1.1717 +expression, or another linear expression enclosed in parentheses.
  1.1718 +
  1.1719 +It is also allowed to use a numeric expression as the primary linear
  1.1720 +expression, in which case the resultant value of the numeric expression
  1.1721 +is automatically converted to a formula that includes the constant term
  1.1722 +only.
  1.1723 +
  1.1724 +\medskip
  1.1725 +
  1.1726 +\noindent{\bf Examples}
  1.1727 +
  1.1728 +\medskip
  1.1729 +
  1.1730 +\noindent
  1.1731 +\begin{tabular}{@{}ll@{}}
  1.1732 +\verb|z|&(unsubscripted variable)\\
  1.1733 +\verb|x[i,j]|&(subscripted variable)\\
  1.1734 +\verb|sum{j in J} (a[i] * x[i,j] + 3 * y)|&(iterated expression)\\
  1.1735 +\verb|if i in I then x[i,j] else 1.5 * z + 3|&(conditional expression)\\
  1.1736 +\verb|(a[i,j] * x[i,j] + y[i-1] + .1)|&(parenthesized expression)\\
  1.1737 +\end{tabular}
  1.1738 +
  1.1739 +\medskip
  1.1740 +
  1.1741 +More general linear expressions containing two or more primary linear
  1.1742 +expressions may be constructed by using certain arithmetic operators.
  1.1743 +
  1.1744 +\medskip
  1.1745 +
  1.1746 +\noindent{\bf Examples}
  1.1747 +
  1.1748 +\medskip
  1.1749 +
  1.1750 +\noindent\verb|2 * x[i-1,j+1] + 3.5 * y[k] + .5 * z|
  1.1751 +
  1.1752 +\noindent\verb|(- x[i,j] + 3.5 * y[k]) / sum{t in T} abs(d[i,j,t])|
  1.1753 +
  1.1754 +\subsubsection{Unsubscripted variables}
  1.1755 +
  1.1756 +If the primary linear expression is an unsubscripted variable (which
  1.1757 +must be 0-dimensional), the resultant formula is that unsubscripted
  1.1758 +variable.
  1.1759 +
  1.1760 +\subsubsection{Subscripted variables}
  1.1761 +
  1.1762 +The primary linear expression, which refers to a subscripted variable,
  1.1763 +has the following syntactic form:
  1.1764 +
  1.1765 +\medskip
  1.1766 +
  1.1767 +\noindent\hfil
  1.1768 +{\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
  1.1769 +
  1.1770 +\medskip
  1.1771 +
  1.1772 +\noindent where {\it name} is the symbolic name of the model variable,
  1.1773 +$i_1$, $i_2$, \dots, $i_n$ are subscripts.
  1.1774 +
  1.1775 +Each subscript must be a numeric or symbolic expression. The number of
  1.1776 +subscripts in the subscript list must be the same as the dimension of
  1.1777 +the model variable with which the subscript list is associated.
  1.1778 +
  1.1779 +Actual values of the subscript expressions are used to identify a
  1.1780 +particular member of the model variable that determines the resultant
  1.1781 +formula, which is an elemental variable associated with corresponding
  1.1782 +member.
  1.1783 +
  1.1784 +\subsubsection{Iterated expressions}
  1.1785 +
  1.1786 +An {\it iterated linear expression} is a primary linear expression,
  1.1787 +which has the following syntactic form:
  1.1788 +
  1.1789 +\medskip
  1.1790 +
  1.1791 +\noindent\hfil
  1.1792 +{\tt sum} {\it indexing-expression} {\it integrand}
  1.1793 +
  1.1794 +\medskip
  1.1795 +
  1.1796 +\noindent where {\it indexing-expression} is an indexing expression,
  1.1797 +which introduces dummy indices and controls iterating, {\it integrand}
  1.1798 +is a linear expression that participates in the operation.
  1.1799 +
  1.1800 +The iterated linear expression is evaluated exactly in the same way as
  1.1801 +the iterated numeric expression (see Subection \ref{itexpr}, page
  1.1802 +\pageref{itexpr}) with exception that the integrand participated in the
  1.1803 +summation is a formula, not a numeric value.
  1.1804 +
  1.1805 +\subsubsection{Conditional expressions}
  1.1806 +
  1.1807 +A {\it conditional linear expression} is a primary linear expression,
  1.1808 +which has one of the following two syntactic forms:
  1.1809 +
  1.1810 +\medskip
  1.1811 +
  1.1812 +\noindent\hfil
  1.1813 +{\tt if} $b$ {\tt then} $f$ {\tt else} $g$
  1.1814 +
  1.1815 +\medskip
  1.1816 +
  1.1817 +\noindent\hspace{127pt}
  1.1818 +{\tt if} $b$ {\tt then} $f$
  1.1819 +
  1.1820 +\medskip
  1.1821 +
  1.1822 +\noindent where $b$ is an logical expression, $f$ and $g$ are linear
  1.1823 +expressions.
  1.1824 +
  1.1825 +The conditional linear expression is evaluated exactly in the same way
  1.1826 +as the conditional numeric expression (see Subsection \ref{ifthen},
  1.1827 +page \pageref{ifthen}) with exception that operands participated in the
  1.1828 +operation are formulae, not numeric values.
  1.1829 +
  1.1830 +\subsubsection{Parenthesized expressions}
  1.1831 +
  1.1832 +Any linear expression may be enclosed in parentheses that syntactically
  1.1833 +makes it a primary linear expression.
  1.1834 +
  1.1835 +Parentheses may be used in linear expressions, as in algebra, to
  1.1836 +specify the desired order in which operations are to be performed.
  1.1837 +Where parentheses are used, the expression within the parentheses is
  1.1838 +evaluated before the resultant formula is used.
  1.1839 +
  1.1840 +The resultant value of the parenthesized expression is the same as the
  1.1841 +value of the expression enclosed within parentheses.
  1.1842 +
  1.1843 +\subsubsection{Arithmetic operators}
  1.1844 +
  1.1845 +In MathProg there exists the following arithmetic operators, which may
  1.1846 +be used in linear expressions:
  1.1847 +
  1.1848 +\medskip
  1.1849 +
  1.1850 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  1.1851 +{\tt+} $f$&unary plus\\
  1.1852 +{\tt-} $f$&unary minus\\
  1.1853 +$f$ {\tt+} $g$&addition\\
  1.1854 +$f$ {\tt-} $g$&subtraction\\
  1.1855 +$x$ {\tt*} $f$, $f$ {\tt*} $x$&multiplication\\
  1.1856 +$f$ {\tt/} $x$&division
  1.1857 +\end{tabular}
  1.1858 +
  1.1859 +\medskip
  1.1860 +
  1.1861 +\noindent where $f$ and $g$ are linear expressions, $x$ is a numeric
  1.1862 +expression (more precisely, a linear expression containing only the
  1.1863 +constant term).
  1.1864 +
  1.1865 +If the expression includes more than one arithmetic operator, all
  1.1866 +operators are performed from left to right according to the hierarchy
  1.1867 +of operations (see below). The resultant value of the expression, which
  1.1868 +contains arithmetic operators, is the result of applying the operators
  1.1869 +to their operands.
  1.1870 +
  1.1871 +\subsubsection{Hierarchy of operations}
  1.1872 +
  1.1873 +The hierarchy of arithmetic operations used in linear expressions is
  1.1874 +the same as for numeric expressions (see Subsection \ref{hierarchy},
  1.1875 +page \pageref{hierarchy}).
  1.1876 +
  1.1877 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.1878 +
  1.1879 +\newpage
  1.1880 +
  1.1881 +\section{Statements}
  1.1882 +
  1.1883 +{\it Statements} are basic units of the model description. In MathProg
  1.1884 +all statements are divided into two categories: declaration statements
  1.1885 +and functional statements.
  1.1886 +
  1.1887 +{\it Declaration statements} (set statement, parameter statement,
  1.1888 +variable statement, constraint statement, and objective statement) are
  1.1889 +used to declare model objects of certain kinds and define certain
  1.1890 +properties of such objects.
  1.1891 +
  1.1892 +{\it Functional statements} (solve statement, check statement, display
  1.1893 +statement, printf statement, loop statement) are intended for
  1.1894 +performing some specific actions.
  1.1895 +
  1.1896 +Note that declaration statements may follow in arbitrary order, which
  1.1897 +does not affect the result of translation. However, any model object
  1.1898 +must be declared before it is referenced in other statements.
  1.1899 +
  1.1900 +\subsection{Set statement}
  1.1901 +
  1.1902 +\medskip
  1.1903 +
  1.1904 +\framebox[345pt][l]{
  1.1905 +\parbox[c][24pt]{345pt}{
  1.1906 +\hspace{6pt} {\tt set} {\it name} {\it alias} {\it domain} {\tt,}
  1.1907 +{\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
  1.1908 +}}
  1.1909 +
  1.1910 +\setlength{\leftmargini}{60pt}
  1.1911 +
  1.1912 +\begin{description}
  1.1913 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.1914 +set;
  1.1915 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
  1.1916 +specifies an alias of the set;
  1.1917 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
  1.1918 +which specifies a subscript domain of the set;
  1.1919 +\item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
  1.1920 +attributes of the set. (Commae preceding attributes may be omitted.)
  1.1921 +\end{description}
  1.1922 +
  1.1923 +\noindent Optional attributes:
  1.1924 +
  1.1925 +\begin{description}
  1.1926 +\item[{\tt dimen} $n$\hspace*{19pt}] specifies the dimension of
  1.1927 +$n$-tuples, which the set consists of;
  1.1928 +\item[{\tt within} {\it expression}]\hspace*{0pt}\\
  1.1929 +specifies a superset which restricts the set or all its members
  1.1930 +(elemental sets) to be within that superset;
  1.1931 +\item[{\tt:=} {\it expression}]\hspace*{0pt}\\
  1.1932 +specifies an elemental set assigned to the set or its members;
  1.1933 +\item[{\tt default} {\it expression}]\hspace*{0pt}\\
  1.1934 +specifies an elemental set assigned to the set or its members whenever
  1.1935 +no appropriate data are available in the data section.
  1.1936 +\end{description}
  1.1937 +
  1.1938 +\newpage
  1.1939 +
  1.1940 +\noindent{\bf Examples}
  1.1941 +
  1.1942 +\begin{verbatim}
  1.1943 +set V;
  1.1944 +set E within V cross V;
  1.1945 +set step{s in 1..maxiter} dimen 2 := if s = 1 then E else
  1.1946 +   step[s-1] union setof{k in V, (i,k) in step[s-1], (k,j)
  1.1947 +   in step[s-1]}(i,j);
  1.1948 +set A{i in I, j in J}, within B[i+1] cross C[j-1], within
  1.1949 +   D diff E, default {('abc',123), (321,'cba')};
  1.1950 +\end{verbatim}
  1.1951 +
  1.1952 +The set statement declares a set. If the subscript domain is not
  1.1953 +specified, the set is a simple set, otherwise it is an array of
  1.1954 +elemental sets.
  1.1955 +
  1.1956 +The {\tt dimen} attribute specifies the dimension of $n$-tuples, which
  1.1957 +the set (if it is a simple set) or its members (if the set is an array
  1.1958 +of elemental sets) consist of, where $n$ must be unsigned integer from
  1.1959 +1 to 20. At most one {\tt dimen} attribute can be specified. If the
  1.1960 +{\tt dimen} attribute is not specified, the dimension of\linebreak
  1.1961 +$n$-tuples is implicitly determined by other attributes (for example,
  1.1962 +if there is a set expression that follows {\tt:=} or the keyword
  1.1963 +{\tt default}, the dimension of $n$-tuples of corresponding elemental
  1.1964 +set is used). If no dimension information is available, {\tt dimen 1}
  1.1965 +is assumed.
  1.1966 +
  1.1967 +The {\tt within} attribute specifies a set expression whose resultant
  1.1968 +value is a superset used to restrict the set (if it is a simple set) or
  1.1969 +its members (if the set is an array of elemental sets) to be within
  1.1970 +that superset. Arbitrary number of {\tt within} attributes may be
  1.1971 +specified in the same set statement.
  1.1972 +
  1.1973 +The assign ({\tt:=}) attribute specifies a set expression used to
  1.1974 +evaluate elemental set(s) assigned to the set (if it is a simple set)
  1.1975 +or its members (if the set is an array of elemental sets). If the
  1.1976 +assign attribute is specified, the set is {\it computable} and
  1.1977 +therefore needs no data to be provided in the data section. If the
  1.1978 +assign attribute is not specified, the set must be provided with data
  1.1979 +in the data section. At most one assign or default attribute can be
  1.1980 +specified for the same set.
  1.1981 +
  1.1982 +The {\tt default} attribute specifies a set expression used to evaluate
  1.1983 +elemental set(s) assigned to the set (if it is a simple set) or its
  1.1984 +members (if the set is an array of elemental sets) whenever
  1.1985 +no appropriate data are available in the data section. If neither
  1.1986 +assign nor default attribute is specified, missing data will cause an
  1.1987 +error.
  1.1988 +
  1.1989 +\subsection{Parameter statement}
  1.1990 +
  1.1991 +\medskip
  1.1992 +
  1.1993 +\framebox[345pt][l]{
  1.1994 +\parbox[c][24pt]{345pt}{
  1.1995 +\hspace{6pt} {\tt param} {\it name} {\it alias} {\it domain} {\tt,}
  1.1996 +{\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
  1.1997 +}}
  1.1998 +
  1.1999 +\setlength{\leftmargini}{60pt}
  1.2000 +
  1.2001 +\begin{description}
  1.2002 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.2003 +parameter;
  1.2004 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
  1.2005 +specifies an alias of the parameter;
  1.2006 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
  1.2007 +which specifies a subscript domain of the parameter;
  1.2008 +\item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
  1.2009 +attributes of the parameter. (Commae preceding attributes may be
  1.2010 +omitted.)
  1.2011 +\end{description}
  1.2012 +
  1.2013 +\noindent Optional attributes:
  1.2014 +
  1.2015 +\begin{description}
  1.2016 +\item[{\tt integer}\hspace*{18.5pt}] specifies that the parameter is
  1.2017 +integer;
  1.2018 +\item[{\tt binary}\hspace*{24pt}] specifies that the parameter is
  1.2019 +binary;
  1.2020 +\item[{\tt symbolic}\hspace*{13.5pt}] specifies that the parameter is
  1.2021 +symbolic;
  1.2022 +\item[{\it relation expression}]\hspace*{0pt}\\
  1.2023 +(where {\it relation} is one of: {\tt<}, {\tt<=}, {\tt=}, {\tt==},
  1.2024 +{\tt>=}, {\tt>}, {\tt<>}, {\tt!=})\\
  1.2025 +specifies a condition that restricts the parameter or its members to
  1.2026 +satisfy that condition;
  1.2027 +\item[{\tt in} {\it expression}]\hspace*{0pt}\\
  1.2028 +specifies a superset that restricts the parameter or its members to be
  1.2029 +in that superset;
  1.2030 +\item[{\tt:=} {\it expression}]\hspace*{0pt}\\
  1.2031 +specifies a value assigned to the parameter or its members;
  1.2032 +\item[{\tt default} {\it expression}]\hspace*{0pt}\\
  1.2033 +specifies a value assigned to the parameter or its members whenever
  1.2034 +no appropriate data are available in the data section.
  1.2035 +\end{description}
  1.2036 +
  1.2037 +\noindent{\bf Examples}
  1.2038 +
  1.2039 +\begin{verbatim}
  1.2040 +param units{raw, prd} >= 0;
  1.2041 +param profit{prd, 1..T+1};
  1.2042 +param N := 20, integer, >= 0, <= 100;
  1.2043 +param comb 'n choose k' {n in 0..N, k in 0..n} :=
  1.2044 +   if k = 0 or k = n then 1 else comb[n-1,k-1] + comb[n-1,k];
  1.2045 +param p{i in I, j in J}, integer, >= 0, <= i+j,
  1.2046 +   in A[i] symdiff B[j], in C[i,j], default 0.5 * (i + j);
  1.2047 +param month symbolic default 'May' in {'Mar', 'Apr', 'May'};
  1.2048 +\end{verbatim}
  1.2049 +
  1.2050 +The parameter statement declares a parameter. If a subscript domain is
  1.2051 +not specified, the parameter is a simple (scalar) parameter, otherwise
  1.2052 +it is a $n$-dimensional array.
  1.2053 +
  1.2054 +The type attributes {\tt integer}, {\tt binary}, and {\tt symbolic}
  1.2055 +qualify the type of values that can be assigned to the parameter as
  1.2056 +shown below:
  1.2057 +
  1.2058 +\medskip
  1.2059 +
  1.2060 +\noindent\hfil
  1.2061 +\begin{tabular}{@{}ll@{}}
  1.2062 +Type attribute&Assigned values\\
  1.2063 +\hline
  1.2064 +(not specified)&Any numeric values\\
  1.2065 +{\tt integer}&Only integer numeric values\\
  1.2066 +{\tt binary}&Either 0 or 1\\
  1.2067 +{\tt symbolic}&Any numeric and symbolic values\\
  1.2068 +\end{tabular}
  1.2069 +
  1.2070 +\newpage
  1.2071 +
  1.2072 +The {\tt symbolic} attribute cannot be specified along with other type
  1.2073 +attributes. Being specified it must precede all other attributes.
  1.2074 +
  1.2075 +The condition attribute specifies an optional condition that restricts
  1.2076 +values assigned to the parameter to satisfy that condition. This
  1.2077 +attribute has the following syntactic forms:
  1.2078 +
  1.2079 +\medskip
  1.2080 +
  1.2081 +\begin{tabular}{@{}ll@{}}
  1.2082 +{\tt<} $v$&check for $x<v$\\
  1.2083 +{\tt<=} $v$&check for $x\leq v$\\
  1.2084 +{\tt=} $v$, {\tt==} $v$&check for $x=v$\\
  1.2085 +{\tt>=} $v$&check for $x\geq v$\\
  1.2086 +{\tt>} $v$&check for $x\geq v$\\
  1.2087 +{\tt<>} $v$, {\tt!=} $v$&check for $x\neq v$\\
  1.2088 +\end{tabular}
  1.2089 +
  1.2090 +\medskip
  1.2091 +
  1.2092 +\noindent where $x$ is a value assigned to the parameter, $v$ is the
  1.2093 +resultant value of a numeric or symbolic expression specified in the
  1.2094 +condition attribute. Arbitrary number of condition attributes can be
  1.2095 +specified for the same parameter. If a value being assigned to the
  1.2096 +parameter during model evaluation violates at least one of specified
  1.2097 +conditions, an error is raised. (Note that symbolic values are ordered
  1.2098 +lexicographically, and any numeric value precedes any symbolic value.)
  1.2099 +
  1.2100 +The {\tt in} attribute is similar to the condition attribute and
  1.2101 +specifies a set expression whose resultant value is a superset used to
  1.2102 +restrict numeric or symbolic values assigned to the parameter to be in
  1.2103 +that superset. Arbitrary number of the {\tt in} attributes can be
  1.2104 +specified for the same parameter. If a value being assigned to the
  1.2105 +parameter during model evaluation is not in at least one of specified
  1.2106 +supersets, an error is raised.
  1.2107 +
  1.2108 +The assign ({\tt:=}) attribute specifies a numeric or symbolic
  1.2109 +expression used to compute a value assigned to the parameter (if it is
  1.2110 +a simple parameter) or its member (if the parameter is an array). If
  1.2111 +the assign attribute is specified, the parameter is {\it computable}
  1.2112 +and therefore needs no data to be provided in the data section. If the
  1.2113 +assign attribute is not specified, the parameter must be provided with
  1.2114 +data in the data section. At most one assign or {\tt default} attribute
  1.2115 +can be specified for the same parameter.
  1.2116 +
  1.2117 +The {\tt default} attribute specifies a numeric or symbolic expression
  1.2118 +used to compute a value assigned to the parameter or its member
  1.2119 +whenever no appropriate data are available in the data section. If
  1.2120 +neither assign nor {\tt default} attribute is specified, missing data
  1.2121 +will cause an error.
  1.2122 +
  1.2123 +\subsection{Variable statement}
  1.2124 +
  1.2125 +\medskip
  1.2126 +
  1.2127 +\framebox[345pt][l]{
  1.2128 +\parbox[c][24pt]{345pt}{
  1.2129 +\hspace{6pt} {\tt var} {\it name} {\it alias} {\it domain} {\tt,}
  1.2130 +{\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
  1.2131 +}}
  1.2132 +
  1.2133 +\setlength{\leftmargini}{60pt}
  1.2134 +
  1.2135 +\begin{description}
  1.2136 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.2137 +variable;
  1.2138 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
  1.2139 +specifies an alias of the variable;
  1.2140 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
  1.2141 +which specifies a subscript domain of the variable;
  1.2142 +\item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
  1.2143 +attributes of the variable. (Commae preceding attributes may be
  1.2144 +omitted.)
  1.2145 +\end{description}
  1.2146 +
  1.2147 +\noindent Optional attributes:
  1.2148 +
  1.2149 +\begin{description}
  1.2150 +\item[{\tt integer}\hspace*{18.5pt}] restricts the variable to be
  1.2151 +integer;
  1.2152 +\item[{\tt binary}\hspace*{24pt}] restricts the variable to be binary;
  1.2153 +\item[{\tt>=} {\it expression}]\hspace*{0pt}\\
  1.2154 +specifies an lower bound of the variable;
  1.2155 +\item[{\tt<=} {\it expression}]\hspace*{0pt}\\
  1.2156 +specifies an upper bound of the variable;
  1.2157 +\item[{\tt=} {\it expression}]\hspace*{0pt}\\
  1.2158 +specifies a fixed value of the variable;
  1.2159 +\end{description}
  1.2160 +
  1.2161 +\noindent{\bf Examples}
  1.2162 +
  1.2163 +\begin{verbatim}
  1.2164 +var x >= 0;
  1.2165 +var y{I,J};
  1.2166 +var make{p in prd}, integer, >= commit[p], <= market[p];
  1.2167 +var store{raw, 1..T+1} >= 0;
  1.2168 +var z{i in I, j in J} >= i+j;
  1.2169 +\end{verbatim}
  1.2170 +
  1.2171 +The variable statement declares a variable. If a subscript domain is
  1.2172 +not specified, the variable is a simple (scalar) variable, otherwise it
  1.2173 +is a $n$-dimensional array of elemental variables.
  1.2174 +
  1.2175 +Elemental variable(s) associated with the model variable (if it is a
  1.2176 +simple variable) or its members (if it is an array) correspond to the
  1.2177 +variables in the LP/MIP problem formulation (see Subsection
  1.2178 +\ref{problem}, page \pageref{problem}). Note that only elemental
  1.2179 +variables actually referenced in some constraints and/or objectives are
  1.2180 +included in the LP/MIP problem instance to be generated.
  1.2181 +
  1.2182 +The type attributes {\tt integer} and {\tt binary} restrict the
  1.2183 +variable to be integer or binary, respectively. If no type attribute is
  1.2184 +specified, the variable is continuous. If all variables in the model
  1.2185 +are continuous, the corresponding problem is of LP class. If there is
  1.2186 +at least one integer or binary variable, the problem is of MIP class.
  1.2187 +
  1.2188 +The lower bound ({\tt>=}) attribute specifies a numeric expression for
  1.2189 +computing an lower bound of the variable. At most one lower bound can
  1.2190 +be specified. By default all variables (except binary ones) have no
  1.2191 +lower bound, so if a variable is required to be non-negative, its zero
  1.2192 +lower bound should be explicitly specified.
  1.2193 +
  1.2194 +The upper bound ({\tt<=}) attribute specifies a numeric expression for
  1.2195 +computing an upper bound of the variable. At most one upper bound
  1.2196 +attribute can be specified.
  1.2197 +
  1.2198 +The fixed value ({\tt=}) attribute specifies a numeric expression for
  1.2199 +computing a value, at which the variable is fixed. This attribute
  1.2200 +cannot be specified along with the bound attributes.
  1.2201 +
  1.2202 +\subsection{Constraint statement}
  1.2203 +
  1.2204 +\medskip
  1.2205 +
  1.2206 +\framebox[345pt][l]{
  1.2207 +\parbox[c][96pt]{345pt}{
  1.2208 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
  1.2209 +{\it expression} {\tt,} {\tt=} {\it expression} {\tt;}
  1.2210 +
  1.2211 +\medskip
  1.2212 +
  1.2213 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
  1.2214 +{\it expression} {\tt,} {\tt<=} {\it expression} {\tt;}
  1.2215 +
  1.2216 +\medskip
  1.2217 +
  1.2218 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
  1.2219 +{\it expression} {\tt,} {\tt>=} {\it expression} {\tt;}
  1.2220 +
  1.2221 +\medskip
  1.2222 +
  1.2223 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
  1.2224 +{\it expression} {\tt,} {\tt<=} {\it expression} {\tt,} {\tt<=}
  1.2225 +{\it expression} {\tt;}
  1.2226 +
  1.2227 +\medskip
  1.2228 +
  1.2229 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
  1.2230 +{\it expression} {\tt,} {\tt>=} {\it expression} {\tt,} {\tt>=}
  1.2231 +{\it expression} {\tt;}
  1.2232 +}}
  1.2233 +
  1.2234 +\setlength{\leftmargini}{60pt}
  1.2235 +
  1.2236 +\begin{description}
  1.2237 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.2238 +constraint;
  1.2239 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
  1.2240 +specifies an alias of the constraint;
  1.2241 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
  1.2242 +which specifies a subscript domain of the constraint;
  1.2243 +\item[\hspace*{54pt}] {\it expression} is a linear expression used to
  1.2244 +compute a component of the constraint. (Commae following expressions
  1.2245 +may be omitted.)
  1.2246 +\end{description}
  1.2247 +
  1.2248 +\begin{description}
  1.2249 +\item[{\rm Note:}\hspace*{31pt}] The keyword {\tt s.t.} may be written
  1.2250 +as {\tt subject to} or as {\tt subj to}, or may be omitted at all.
  1.2251 +\end{description}
  1.2252 +
  1.2253 +\noindent{\bf Examples}
  1.2254 +
  1.2255 +\begin{verbatim}
  1.2256 +s.t. r: x + y + z, >= 0, <= 1;
  1.2257 +limit{t in 1..T}: sum{j in prd} make[j,t] <= max_prd;
  1.2258 +subject to balance{i in raw, t in 1..T}: store[i,t+1] -
  1.2259 +   store[i,t] - sum{j in prd} units[i,j] * make[j,t];
  1.2260 +subject to rlim 'regular-time limit' {t in time}:
  1.2261 +sum{p in prd} pt[p] * rprd[p,t] <= 1.3 * dpp[t] * crews[t];
  1.2262 +\end{verbatim}
  1.2263 +
  1.2264 +The constraint statement declares a constraint. If a subscript domain
  1.2265 +is not specified, the constraint is a simple (scalar) constraint,
  1.2266 +otherwise it is a $n$-dimensional array of elemental constraints.
  1.2267 +
  1.2268 +Elemental constraint(s) associated with the model constraint (if it is
  1.2269 +a simple constraint) or its members (if it is an array) correspond to
  1.2270 +the linear constraints in the LP/MIP problem formulation (see
  1.2271 +Subsection \ref{problem}, page \pageref{problem}).
  1.2272 +
  1.2273 +If the constraint has the form of equality or single inequality, i.e.
  1.2274 +includes two expressions, one of which follows the colon and other
  1.2275 +follows the relation sign {\tt=}, {\tt<=}, or {\tt>=}, both expressions
  1.2276 +in the statement can be linear expressions. If the constraint has the
  1.2277 +form of double inequality, i.e. includes three expressions, the middle
  1.2278 +expression can be a linear expression while the leftmost and rightmost
  1.2279 +ones can be only numeric expressions.
  1.2280 +
  1.2281 +Generating the model is, roughly speaking, generating its constraints,
  1.2282 +which are always evaluated for the entire subscript domain. Evaluation
  1.2283 +of the constraints leads, in turn, to evaluation of other model objects
  1.2284 +such as sets, parameters, and variables.
  1.2285 +
  1.2286 +Constructing an actual linear constraint included in the problem
  1.2287 +instance, which (constraint) corresponds to a particular elemental
  1.2288 +constraint, is performed as follows.
  1.2289 +
  1.2290 +If the constraint has the form of equality or single inequality,
  1.2291 +evaluation of both linear expressions gives two resultant linear forms:
  1.2292 +$$\begin{array}{r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r}
  1.2293 +f&=&a_1x_1&+&a_2x_2&+\dots+&a_nx_n&+&a_0,\\
  1.2294 +g&=&b_1x_1&+&a_2x_2&+\dots+&a_nx_n&+&b_0,\\
  1.2295 +\end{array}$$
  1.2296 +where $x_1$, $x_2$, \dots, $x_n$ are elemental variables; $a_1$, $a_2$,
  1.2297 +\dots, $a_n$, $b_1$, $b_2$, \dots, $b_n$ are numeric coefficients;
  1.2298 +$a_0$ and $b_0$ are constant terms. Then all linear terms of $f$ and
  1.2299 +$g$ are carried to the left-hand side, and the constant terms are
  1.2300 +carried to the right-hand side, that gives the final elemental
  1.2301 +constraint in the standard form:
  1.2302 +$$(a_1-b_1)x_1+(a_2-b_2)x_2+\dots+(a_n-b_n)x_n\left\{
  1.2303 +\begin{array}{@{}c@{}}=\\\leq\\\geq\\\end{array}\right\}b_0-a_0.$$
  1.2304 +
  1.2305 +If the constraint has the form of double inequality, evaluation of the
  1.2306 +middle linear expression gives the resultant linear form:
  1.2307 +$$f=a_1x_1+a_2x_2+\dots+a_nx_n+a_0,$$
  1.2308 +and evaluation of the leftmost and rightmost numeric expressions gives
  1.2309 +two numeric values $l$ and $u$, respectively. Then the constant term of
  1.2310 +the linear form is carried to both left-hand and right-handsides that
  1.2311 +gives the final elemental constraint in the standard form:
  1.2312 +$$l-a_0\leq a_1x_1+a_2x_2+\dots+a_nx_n\leq u-a_0.$$
  1.2313 +
  1.2314 +\subsection{Objective statement}
  1.2315 +
  1.2316 +\medskip
  1.2317 +
  1.2318 +\framebox[345pt][l]{
  1.2319 +\parbox[c][44pt]{345pt}{
  1.2320 +\hspace{6pt} {\tt minimize} {\it name} {\it alias} {\it domain} {\tt:}
  1.2321 +{\it expression} {\tt;}
  1.2322 +
  1.2323 +\medskip
  1.2324 +
  1.2325 +\hspace{6pt} {\tt maximize} {\it name} {\it alias} {\it domain} {\tt:}
  1.2326 +{\it expression} {\tt;}
  1.2327 +}}
  1.2328 +
  1.2329 +\setlength{\leftmargini}{60pt}
  1.2330 +
  1.2331 +\begin{description}
  1.2332 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.2333 +objective;
  1.2334 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
  1.2335 +specifies an alias of the objective;
  1.2336 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
  1.2337 +which specifies a subscript domain of the objective;
  1.2338 +\item[\hspace*{54pt}] {\it expression} is a linear expression used to
  1.2339 +compute the linear form of the objective.
  1.2340 +\end{description}
  1.2341 +
  1.2342 +\noindent{\bf Examples}
  1.2343 +
  1.2344 +\begin{verbatim}
  1.2345 +minimize obj: x + 1.5 * (y + z);
  1.2346 +maximize total_profit: sum{p in prd} profit[p] * make[p];
  1.2347 +\end{verbatim}
  1.2348 +
  1.2349 +The objective statement declares an objective. If a subscript domain is
  1.2350 +not specified, the objective is a simple (scalar) objective. Otherwise
  1.2351 +it is a $n$-dimensional array of elemental objectives.
  1.2352 +
  1.2353 +Elemental objective(s) associated with the model objective (if it is a
  1.2354 +simple objective) or its members (if it is an array) correspond to
  1.2355 +general linear constraints in the LP/MIP problem formulation (see
  1.2356 +Subsection \ref{problem}, page \pageref{problem}). However, unlike
  1.2357 +constraints the corresponding linear forms are free (unbounded).
  1.2358 +
  1.2359 +Constructing an actual linear constraint included in the problem
  1.2360 +instance, which (constraint) corresponds to a particular elemental
  1.2361 +constraint, is performed as follows. The linear expression specified in
  1.2362 +the objective statement is evaluated that, gives the resultant linear
  1.2363 +form:
  1.2364 +$$f=a_1x_1+a_2x_2+\dots+a_nx_n+a_0,$$
  1.2365 +where $x_1$, $x_2$, \dots, $x_n$ are elemental variables; $a_1$, $a_2$,
  1.2366 +\dots, $a_n$ are numeric coefficients; $a_0$ is the constant term. Then
  1.2367 +the linear form is used to construct the final elemental constraint in
  1.2368 +the standard form:
  1.2369 +$$-\infty<a_1x_1+a_2x_2+\dots+a_nx_n+a_0<+\infty.$$
  1.2370 +
  1.2371 +As a rule the model description contains only one objective statement
  1.2372 +that defines the objective function used in the problem instance.
  1.2373 +However, it is allowed to declare arbitrary number of objectives, in
  1.2374 +which case the actual objective function is the first objective
  1.2375 +encountered in the model description. Other objectives are also
  1.2376 +included in the problem instance, but they do not affect the objective
  1.2377 +function.
  1.2378 +
  1.2379 +\subsection{Solve statement}
  1.2380 +
  1.2381 +\medskip
  1.2382 +
  1.2383 +\framebox[345pt][l]{
  1.2384 +\parbox[c][24pt]{345pt}{
  1.2385 +\hspace{6pt} {\tt solve} {\tt;}
  1.2386 +}}
  1.2387 +
  1.2388 +\setlength{\leftmargini}{60pt}
  1.2389 +
  1.2390 +\begin{description}
  1.2391 +\item[{\rm Note:}\hspace*{31pt}] The solve statement is optional and
  1.2392 +can be used only once. If no solve statement is used, one is assumed at
  1.2393 +the end of the model section.
  1.2394 +\end{description}
  1.2395 +
  1.2396 +The solve statement causes the model to be solved, that means computing
  1.2397 +numeric values of all model variables. This allows using variables in
  1.2398 +statements below the solve statement in the same way as if they were
  1.2399 +numeric parameters.
  1.2400 +
  1.2401 +Note that the variable, constraint, and objective statements cannot be
  1.2402 +used below the solve statement, i.e. all principal components of the
  1.2403 +model must be declared above the solve statement.
  1.2404 +
  1.2405 +\subsection{Check statement}
  1.2406 +
  1.2407 +\medskip
  1.2408 +
  1.2409 +\framebox[345pt][l]{
  1.2410 +\parbox[c][24pt]{345pt}{
  1.2411 +\hspace{6pt} {\tt check} {\it domain} {\tt:} {\it expression} {\tt;}
  1.2412 +}}
  1.2413 +
  1.2414 +\setlength{\leftmargini}{60pt}
  1.2415 +
  1.2416 +\begin{description}
  1.2417 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
  1.2418 +expression, which specifies a subscript domain of the check statement;
  1.2419 +\item[\hspace*{54pt}] {\it expression} is an logical expression which
  1.2420 +specifies the logical condition to be checked. (The colon preceding
  1.2421 +{\it expression} may be omitted.)
  1.2422 +\end{description}
  1.2423 +
  1.2424 +\noindent{\bf Examples}
  1.2425 +
  1.2426 +\begin{verbatim}
  1.2427 +check: x + y <= 1 and x >= 0 and y >= 0;
  1.2428 +check sum{i in ORIG} supply[i] = sum{j in DEST} demand[j];
  1.2429 +check{i in I, j in 1..10}: S[i,j] in U[i] union V[j];
  1.2430 +\end{verbatim}
  1.2431 +
  1.2432 +The check statement allows checking the resultant value of an logical
  1.2433 +expression specified in the statement. If the value is {\it false}, an
  1.2434 +error is reported.
  1.2435 +
  1.2436 +If the subscript domain is not specified, the check is performed only
  1.2437 +once. Specifying the subscript domain allows performing multiple checks
  1.2438 +for every\linebreak $n$-tuple in the domain set. In the latter case the
  1.2439 +logical expression may include dummy indices introduced in
  1.2440 +corresponding indexing expression.
  1.2441 +
  1.2442 +\subsection{Display statement}
  1.2443 +
  1.2444 +\medskip
  1.2445 +
  1.2446 +\framebox[345pt][l]{
  1.2447 +\parbox[c][24pt]{345pt}{
  1.2448 +\hspace{6pt} {\tt display} {\it domain} {\tt:} {\it item} {\tt,}
  1.2449 +\dots {\tt,} {\it item} {\tt;}
  1.2450 +}}
  1.2451 +
  1.2452 +\setlength{\leftmargini}{60pt}
  1.2453 +
  1.2454 +\begin{description}
  1.2455 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
  1.2456 +expression, which specifies a subscript domain of the check statement;
  1.2457 +\item[\hspace*{54pt}] {\it item}, \dots, {\it item} are items to be
  1.2458 +displayed. (The colon preceding the first item may be omitted.)
  1.2459 +\end{description}
  1.2460 +
  1.2461 +\noindent{\bf Examples}
  1.2462 +
  1.2463 +\begin{verbatim}
  1.2464 +display: 'x =', x, 'y =', y, 'z =', z;
  1.2465 +display sqrt(x ** 2 + y ** 2 + z ** 2);
  1.2466 +display{i in I, j in J}: i, j, a[i,j], b[i,j];
  1.2467 +\end{verbatim}
  1.2468 +
  1.2469 +\newpage
  1.2470 +
  1.2471 +The display statement evaluates all items specified in the statement
  1.2472 +and writes their values to the terminal in plain text format.
  1.2473 +
  1.2474 +If a subscript domain is not specified, items are evaluated and then
  1.2475 +displayed only once. Specifying the subscript domain causes items to be
  1.2476 +evaluated and displayed for every $n$-tuple in the domain set. In the
  1.2477 +latter case items may include dummy indices introduced in corresponding
  1.2478 +indexing expression.
  1.2479 +
  1.2480 +An item to be displayed can be a model object (set, parameter, variable,
  1.2481 +constraint, objective) or an expression.
  1.2482 +
  1.2483 +If the item is a computable object (i.e. a set or parameter provided
  1.2484 +with the assign attribute), the object is evaluated over the entire
  1.2485 +domain and then its content (i.e. the content of the object array) is
  1.2486 +displayed. Otherwise, if the item is not a computable object, only its
  1.2487 +current content (i.e. members actually generated during the model
  1.2488 +evaluation) is displayed.
  1.2489 +
  1.2490 +If the item is an expression, the expression is evaluated and its
  1.2491 +resultant value is displayed.
  1.2492 +
  1.2493 +\subsection{Printf statement}
  1.2494 +
  1.2495 +\medskip
  1.2496 +
  1.2497 +\framebox[345pt][l]{
  1.2498 +\parbox[c][60pt]{345pt}{
  1.2499 +\hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
  1.2500 +{\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt;}
  1.2501 +
  1.2502 +\medskip
  1.2503 +
  1.2504 +\hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
  1.2505 +{\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt>}
  1.2506 +{\it filename} {\tt;}
  1.2507 +
  1.2508 +\medskip
  1.2509 +
  1.2510 +\hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
  1.2511 +{\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt>>}
  1.2512 +{\it filename} {\tt;}
  1.2513 +}}
  1.2514 +
  1.2515 +\setlength{\leftmargini}{60pt}
  1.2516 +
  1.2517 +\begin{description}
  1.2518 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
  1.2519 +expression, which specifies a subscript domain of the printf statement;
  1.2520 +\item[\hspace*{54pt}] {\it format} is a symbolic expression whose value
  1.2521 +specifies a format control string. (The colon preceding the format
  1.2522 +expression may be omitted.)
  1.2523 +\item[\hspace*{54pt}] {\it expression}, \dots, {\it expression} are
  1.2524 +zero or more expressions whose values have to be formatted and printed.
  1.2525 +Each expression must be of numeric, symbolic, or logical type.
  1.2526 +\item[\hspace*{54pt}] {\it filename} is a symbolic expression whose
  1.2527 +value specifies a name of a text file, to which the output is
  1.2528 +redirected. The flag {\tt>} means creating a new empty file while the
  1.2529 +flag {\tt>>} means appending the output to an existing file. If no file
  1.2530 +name is specified, the output is written to the terminal.
  1.2531 +\end{description}
  1.2532 +
  1.2533 +\noindent{\bf Examples}
  1.2534 +
  1.2535 +\begin{verbatim}
  1.2536 +printf 'Hello, world!\n';
  1.2537 +printf: "x = %.3f; y = %.3f; z = %.3f\n",
  1.2538 +   x, y, z > "result.txt";
  1.2539 +printf{i in I, j in J}: "flow from %s to %s is %d\n",
  1.2540 +   i, j, x[i,j] >> result_file & ".txt";
  1.2541 +\end{verbatim}
  1.2542 +
  1.2543 +\newpage
  1.2544 +
  1.2545 +\begin{verbatim}
  1.2546 +printf{i in I} 'total flow from %s is %g\n',
  1.2547 +   i, sum{j in J} x[i,j];
  1.2548 +printf{k in K} "x[%s] = " & (if x[k] < 0 then "?" else "%g"),
  1.2549 +   k, x[k];
  1.2550 +\end{verbatim}
  1.2551 +
  1.2552 +The printf statement is similar to the display statement, however, it
  1.2553 +allows formatting data to be written.
  1.2554 +
  1.2555 +If a subscript domain is not specified, the printf statement is
  1.2556 +executed only once. Specifying a subscript domain causes executing the
  1.2557 +printf statement for every $n$-tuple in the domain set. In the latter
  1.2558 +case the format and expression may include dummy indices introduced in
  1.2559 +corresponding indexing expression.
  1.2560 +
  1.2561 +The format control string is a value of the symbolic expression
  1.2562 +{\it format} specified in the printf statement. It is composed of zero
  1.2563 +or more directives as follows: ordinary characters (not {\tt\%}), which
  1.2564 +are copied unchanged to the output stream, and conversion
  1.2565 +specifications, each of which causes evaluating corresponding
  1.2566 +expression specified in the printf statement, formatting it, and
  1.2567 +writing its resultant value to the output stream.
  1.2568 +
  1.2569 +Conversion specifications that may be used in the format control string
  1.2570 +are the following: {\tt d}, {\tt i}, {\tt f}, {\tt F}, {\tt e}, {\tt E},
  1.2571 +{\tt g}, {\tt G}, and {\tt s}. These specifications have the same
  1.2572 +syntax and semantics as in the C programming language.
  1.2573 +
  1.2574 +\subsection{For statement}
  1.2575 +
  1.2576 +\medskip
  1.2577 +
  1.2578 +\framebox[345pt][l]{
  1.2579 +\parbox[c][44pt]{345pt}{
  1.2580 +\hspace{6pt} {\tt for} {\it domain} {\tt:} {\it statement} {\tt;}
  1.2581 +
  1.2582 +\medskip
  1.2583 +
  1.2584 +\hspace{6pt} {\tt for} {\it domain} {\tt:} {\tt\{} {\it statement}
  1.2585 +\dots {\it statement} {\tt\}} {\tt;}
  1.2586 +}}
  1.2587 +
  1.2588 +\setlength{\leftmargini}{60pt}
  1.2589 +
  1.2590 +\begin{description}
  1.2591 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an indexing
  1.2592 +expression which specifies a subscript domain of the for statement.
  1.2593 +(The colon following the indexing expression may be omitted.)
  1.2594 +\item[\hspace*{54pt}] {\it statement} is a statement, which should be
  1.2595 +executed under control of the for statement;
  1.2596 +\item[\hspace*{54pt}] {\it statement}, \dots, {\it statement} is a
  1.2597 +sequence of statements (enclosed in curly braces), which should be
  1.2598 +executed under control of the for statement.
  1.2599 +\end{description}
  1.2600 +
  1.2601 +\begin{description}
  1.2602 +\item[{\rm Note:}\hspace*{31pt}] Only the following statements can be
  1.2603 +used within the for statement: check, display, printf, and another for.
  1.2604 +\end{description}
  1.2605 +
  1.2606 +\noindent{\bf Examples}
  1.2607 +
  1.2608 +\begin{verbatim}
  1.2609 +for {(i,j) in E: i != j}
  1.2610 +{  printf "flow from %s to %s is %g\n", i, j, x[i,j];
  1.2611 +   check x[i,j] >= 0;
  1.2612 +}
  1.2613 +\end{verbatim}
  1.2614 +
  1.2615 +\newpage
  1.2616 +
  1.2617 +\begin{verbatim}
  1.2618 +for {i in 1..n}
  1.2619 +{  for {j in 1..n} printf " %s", if x[i,j] then "Q" else ".";
  1.2620 +   printf("\n");
  1.2621 +}
  1.2622 +for {1..72} printf("*");
  1.2623 +\end{verbatim}
  1.2624 +
  1.2625 +The for statement causes a statement or a sequence of statements
  1.2626 +specified as part of the for statement to be executed for every
  1.2627 +$n$-tuple in the domain set. Thus, statements within the for statement
  1.2628 +may include dummy indices introduced in corresponding indexing
  1.2629 +expression.
  1.2630 +
  1.2631 +\subsection{Table statement}
  1.2632 +
  1.2633 +\medskip
  1.2634 +
  1.2635 +\framebox[345pt][l]{
  1.2636 +\parbox[c][68pt]{345pt}{
  1.2637 +\hspace{6pt} {\tt table} {\it name} {\it alias} {\tt IN} {\it driver}
  1.2638 +{\it arg} \dots {\it arg} {\tt:}
  1.2639 +
  1.2640 +\hspace{6pt} {\tt\ \ \ \ \ } {\it set} {\tt<-} {\tt[} {\it fld} {\tt,}
  1.2641 +\dots {\tt,} {\it fld} {\tt]} {\tt,} {\it par} {\tt\textasciitilde}
  1.2642 +{\it fld} {\tt,} \dots {\tt,} {\it par} {\tt\textasciitilde} {\it fld}
  1.2643 +{\tt;}
  1.2644 +
  1.2645 +\medskip
  1.2646 +
  1.2647 +\hspace{6pt} {\tt table} {\it name} {\it alias} {\it domain} {\tt OUT}
  1.2648 +{\it driver} {\it arg} \dots {\it arg} {\tt:}
  1.2649 +
  1.2650 +\hspace{6pt} {\tt\ \ \ \ \ } {\it expr} {\tt\textasciitilde} {\it fld}
  1.2651 +{\tt,} \dots {\tt,} {\it expr} {\tt\textasciitilde} {\it fld} {\tt;}
  1.2652 +}}
  1.2653 +
  1.2654 +\setlength{\leftmargini}{60pt}
  1.2655 +
  1.2656 +\begin{description}
  1.2657 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.2658 +table;
  1.2659 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
  1.2660 +specifies an alias of the table;
  1.2661 +\item[\hspace*{54pt}] {\it domain} is an indexing expression, which
  1.2662 +specifies a subscript domain of the (output) table;
  1.2663 +\item[\hspace*{54pt}] {\tt IN} means reading data from the input table;
  1.2664 +\item[\hspace*{54pt}] {\tt OUT} means writing data to the output table;
  1.2665 +\item[\hspace*{54pt}] {\it driver} is a symbolic expression, which
  1.2666 +specifies the driver used to access the table (for details see Section
  1.2667 +\ref{drivers}, page \pageref{drivers});
  1.2668 +\item[\hspace*{54pt}] {\it arg} is an optional symbolic expression,
  1.2669 +which is an argument pass\-ed to the table driver. This symbolic
  1.2670 +expression must not include dummy indices specified in the domain;
  1.2671 +\item[\hspace*{54pt}] {\it set} is the name of an optional simple set
  1.2672 +called {\it control set}. It can be omitted along with the delimiter
  1.2673 +{\tt<-};
  1.2674 +\item[\hspace*{54pt}] {\it fld} is a field name. Within square brackets
  1.2675 +at least one field should be specified. The field name following
  1.2676 +a parameter name or expression is optional and can be omitted along
  1.2677 +with the delimiter {\tt\textasciitilde}, in which case the name of
  1.2678 +corresponding model object is used as the field name;
  1.2679 +\item[\hspace*{54pt}] {\it par} is a symbolic name of a model parameter;
  1.2680 +\item[\hspace*{54pt}] {\it expr} is a numeric or symbolic expression.
  1.2681 +\end{description}
  1.2682 +
  1.2683 +\newpage
  1.2684 +
  1.2685 +\noindent{\bf Examples}
  1.2686 +
  1.2687 +\begin{verbatim}
  1.2688 +table data IN "CSV" "data.csv":
  1.2689 +   S <- [FROM,TO], d~DISTANCE, c~COST;
  1.2690 +table result{(f,t) in S} OUT "CSV" "result.csv":
  1.2691 +   f~FROM, t~TO, x[f,t]~FLOW;
  1.2692 +\end{verbatim}
  1.2693 +
  1.2694 +The table statement allows reading data from a table into model
  1.2695 +objects such as sets and (non-scalar) parameters as well as writing
  1.2696 +data from the model to a table.
  1.2697 +
  1.2698 +\subsubsection{Table structure}
  1.2699 +
  1.2700 +A {\it data table} is an (unordered) set of {\it records}, where each
  1.2701 +record consists of the same number of {\it fields}, and each field is
  1.2702 +provided with a unique symbolic name called the {\it field name}. For
  1.2703 +example:
  1.2704 +
  1.2705 +\bigskip
  1.2706 +
  1.2707 +\begin{tabular}{@{\hspace*{38mm}}c@{\hspace*{11mm}}c@{\hspace*{10mm}}c
  1.2708 +@{\hspace*{9mm}}c}
  1.2709 +First&Second&&Last\\
  1.2710 +field&field&.\ \ .\ \ .&field\\
  1.2711 +$\downarrow$&$\downarrow$&&$\downarrow$\\
  1.2712 +\end{tabular}
  1.2713 +
  1.2714 +\begin{tabular}{ll@{}}
  1.2715 +Table header&$\rightarrow$\\
  1.2716 +First record&$\rightarrow$\\
  1.2717 +Second record&$\rightarrow$\\
  1.2718 +\\
  1.2719 +\hfil .\ \ .\ \ .\\
  1.2720 +\\
  1.2721 +Last record&$\rightarrow$\\
  1.2722 +\end{tabular}
  1.2723 +\begin{tabular}{|l|l|c|c|}
  1.2724 +\hline
  1.2725 +{\tt FROM}&{\tt TO}&{\tt DISTANCE}&{\tt COST}\\
  1.2726 +\hline
  1.2727 +{\tt Seattle}  &{\tt New-York}&{\tt 2.5}&{\tt 0.12}\\
  1.2728 +{\tt Seattle}  &{\tt Chicago} &{\tt 1.7}&{\tt 0.08}\\
  1.2729 +{\tt Seattle}  &{\tt Topeka}  &{\tt 1.8}&{\tt 0.09}\\
  1.2730 +{\tt San-Diego}&{\tt New-York}&{\tt 2.5}&{\tt 0.15}\\
  1.2731 +{\tt San-Diego}&{\tt Chicago} &{\tt 1.8}&{\tt 0.10}\\
  1.2732 +{\tt San-Diego}&{\tt Topeka}  &{\tt 1.4}&{\tt 0.07}\\
  1.2733 +\hline
  1.2734 +\end{tabular}
  1.2735 +
  1.2736 +\subsubsection{Reading data from input table}
  1.2737 +
  1.2738 +The input table statement causes reading data from the specified table
  1.2739 +record by record.
  1.2740 +
  1.2741 +Once a next record has been read, numeric or symbolic values of fields,
  1.2742 +whose names are enclosed in square brackets in the table statement, are
  1.2743 +gathered into $n$-tuple, and if the control set is specified in the
  1.2744 +table statement, this $n$-tuple is added to it. Besides, a numeric or
  1.2745 +symbolic value of each field associated with a model parameter is
  1.2746 +assigned to the parameter member identified by subscripts, which are
  1.2747 +components of the $n$-tuple just read.
  1.2748 +
  1.2749 +For example, the following input table statement:
  1.2750 +
  1.2751 +\medskip
  1.2752 +
  1.2753 +\noindent\hfil
  1.2754 +\verb|table data IN "...": S <- [FROM,TO], d~DISTANCE, c~COST;|
  1.2755 +
  1.2756 +\medskip
  1.2757 +
  1.2758 +\noindent
  1.2759 +causes reading values of four fields named {\tt FROM}, {\tt TO},
  1.2760 +{\tt DISTANCE}, and {\tt COST} from each record of the specified table.
  1.2761 +Values of fields {\tt FROM} and {\tt TO} give a pair $(f,t)$, which is
  1.2762 +added to the control set {\tt S}. The value of field {\tt DISTANCE} is
  1.2763 +assigned to parameter member ${\tt d}[f,t]$, and the value of field
  1.2764 +{\tt COST} is assigned to parameter member ${\tt c}[f,t]$.
  1.2765 +
  1.2766 +Note that the input table may contain extra fields whose names are not
  1.2767 +specified in the table statement, in which case values of these fields
  1.2768 +on reading the table are ignored.
  1.2769 +
  1.2770 +\subsubsection{Writing data to output table}
  1.2771 +
  1.2772 +The output table statement causes writing data to the specified table.
  1.2773 +Note that some drivers (namely, CSV and xBASE) destroy the output table
  1.2774 +before writing data, i.e. delete all its existing records.
  1.2775 +
  1.2776 +Each $n$-tuple in the specified domain set generates one record written
  1.2777 +to the output table. Values of fields are numeric or symbolic values of
  1.2778 +corresponding expressions specified in the table statement. These
  1.2779 +expressions are evaluated for each $n$-tuple in the domain set and,
  1.2780 +thus, may include dummy indices introduced in the corresponding indexing
  1.2781 +expression.
  1.2782 +
  1.2783 +For example, the following output table statement:
  1.2784 +
  1.2785 +\medskip
  1.2786 +
  1.2787 +\noindent
  1.2788 +\verb|   table result{(f,t) in S} OUT "...": f~FROM, t~TO, x[f,t]~FLOW;|
  1.2789 +
  1.2790 +\medskip
  1.2791 +
  1.2792 +\noindent
  1.2793 +causes writing records, by one record for each pair $(f,t)$ in set
  1.2794 +{\tt S}, to the output table, where each record consists of three
  1.2795 +fields named {\tt FROM}, {\tt TO}, and {\tt FLOW}. The values written
  1.2796 +to fields {\tt FROM} and {\tt TO} are current values of dummy indices
  1.2797 +{\tt f} and {\tt t}, and the value written to field {\tt FLOW} is
  1.2798 +a value of member ${\tt x}[f,t]$ of corresponding subscripted parameter
  1.2799 +or variable.
  1.2800 +
  1.2801 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.2802 +
  1.2803 +\newpage
  1.2804 +
  1.2805 +\section{Model data}
  1.2806 +
  1.2807 +{\it Model data} include elemental sets, which are ``values'' of model
  1.2808 +sets, and numeric and symbolic values of model parameters.
  1.2809 +
  1.2810 +In MathProg there are two different ways to saturate model sets and
  1.2811 +parameters with data. One way is simply providing necessary data using
  1.2812 +the assign attribute. However, in many cases it is more practical to
  1.2813 +separate the model itself and particular data needed for the model. For
  1.2814 +the latter reason in MathProg there is another way, when the model
  1.2815 +description is divided into two parts: model section and data section.
  1.2816 +
  1.2817 +A {\it model section} is a main part of the model description that
  1.2818 +contains declarations of all model objects and is common for all
  1.2819 +problems based on that model.
  1.2820 +
  1.2821 +A {\it data section} is an optional part of the model description that
  1.2822 +contains model data specific for a particular problem.
  1.2823 +
  1.2824 +In MathProg model and data sections can be placed either in one text
  1.2825 +file or in two separate text files.
  1.2826 +
  1.2827 +1. If both model and data sections are placed in one file, the file is
  1.2828 +composed as follows:
  1.2829 +
  1.2830 +\bigskip
  1.2831 +
  1.2832 +\noindent\hfil
  1.2833 +\framebox{\begin{tabular}{l}
  1.2834 +{\it statement}{\tt;}\\
  1.2835 +{\it statement}{\tt;}\\
  1.2836 +\hfil.\ \ .\ \ .\\
  1.2837 +{\it statement}{\tt;}\\
  1.2838 +{\tt data;}\\
  1.2839 +{\it data block}{\tt;}\\
  1.2840 +{\it data block}{\tt;}\\
  1.2841 +\hfil.\ \ .\ \ .\\
  1.2842 +{\it data block}{\tt;}\\
  1.2843 +{\tt end;}
  1.2844 +\end{tabular}}
  1.2845 +
  1.2846 +\bigskip
  1.2847 +
  1.2848 +2. If the model and data sections are placed in two separate files, the
  1.2849 +files are composed as follows:
  1.2850 +
  1.2851 +\bigskip
  1.2852 +
  1.2853 +\noindent\hfil
  1.2854 +\begin{tabular}{@{}c@{}}
  1.2855 +\framebox{\begin{tabular}{l}
  1.2856 +{\it statement}{\tt;}\\
  1.2857 +{\it statement}{\tt;}\\
  1.2858 +\hfil.\ \ .\ \ .\\
  1.2859 +{\it statement}{\tt;}\\
  1.2860 +{\tt end;}\\
  1.2861 +\end{tabular}}\\
  1.2862 +\\\\Model file\\
  1.2863 +\end{tabular}
  1.2864 +\hspace{32pt}
  1.2865 +\begin{tabular}{@{}c@{}}
  1.2866 +\framebox{\begin{tabular}{l}
  1.2867 +{\tt data;}\\
  1.2868 +{\it data block}{\tt;}\\
  1.2869 +{\it data block}{\tt;}\\
  1.2870 +\hfil.\ \ .\ \ .\\
  1.2871 +{\it data block}{\tt;}\\
  1.2872 +{\tt end;}\\
  1.2873 +\end{tabular}}\\
  1.2874 +\\Data file\\
  1.2875 +\end{tabular}
  1.2876 +
  1.2877 +\bigskip
  1.2878 +
  1.2879 +\begin{description}
  1.2880 +\item[{\rm Note:}\hspace*{31pt}] If the data section is placed in a
  1.2881 +separate file, the keyword {\tt data} is optional and may be omitted
  1.2882 +along with the semicolon that follows it.
  1.2883 +\end{description}
  1.2884 +
  1.2885 +\subsection{Coding data section}
  1.2886 +
  1.2887 +The {\it data section} is a sequence of data blocks in various formats,
  1.2888 +which are discussed in following subsections. The order, in which data
  1.2889 +blocks follow in the data section, may be arbitrary, not necessarily
  1.2890 +the same, in which corresponding model objects follow in the model
  1.2891 +section.
  1.2892 +
  1.2893 +The rules of coding the data section are commonly the same as the rules
  1.2894 +of coding the model description (see Subsection \ref{coding}, page
  1.2895 +\pageref{coding}), i.e. data blocks are composed from basic lexical
  1.2896 +units such as symbolic names, numeric and string literals, keywords,
  1.2897 +delimiters, and comments. However, for the sake of convenience and
  1.2898 +improving readability there is one deviation from the common rule: if
  1.2899 +a string literal consists of only alphanumeric characters (including
  1.2900 +the underscore character), the signs {\tt+} and {\tt-}, and/or the
  1.2901 +decimal point, it may be coded without bordering by (single or double)
  1.2902 +quotes.
  1.2903 +
  1.2904 +All numeric and symbolic material provided in the data section is coded
  1.2905 +in the form of numbers and symbols, i.e. unlike the model section
  1.2906 +no expressions are allowed in the data section. Nevertheless, the signs
  1.2907 +{\tt+} and {\tt-} can precede numeric literals to allow coding signed
  1.2908 +numeric quantities, in which case there must be no white-space
  1.2909 +characters between the sign and following numeric literal (if there is
  1.2910 +at least one white-space, the sign and following numeric literal are
  1.2911 +recognized as two different lexical units).
  1.2912 +
  1.2913 +\subsection{Set data block}
  1.2914 +
  1.2915 +\medskip
  1.2916 +
  1.2917 +\framebox[345pt][l]{
  1.2918 +\parbox[c][44pt]{345pt}{
  1.2919 +\hspace{6pt} {\tt set} {\it name} {\tt,} {\it record} {\tt,} \dots
  1.2920 +{\tt,} {\it record} {\tt;}
  1.2921 +
  1.2922 +\medskip
  1.2923 +
  1.2924 +\hspace{6pt} {\tt set} {\it name} {\tt[} {\it symbol} {\tt,} \dots
  1.2925 +{\tt,} {\it symbol} {\tt]} {\tt,} {\it record} {\tt,} \dots {\tt,}
  1.2926 +{\it record} {\tt;}
  1.2927 +}}
  1.2928 +
  1.2929 +\setlength{\leftmargini}{60pt}
  1.2930 +
  1.2931 +\begin{description}
  1.2932 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.2933 +set;
  1.2934 +\item[\hspace*{54pt}] {\it symbol}, \dots, {\it symbol} are subscripts,
  1.2935 +which specify a particular member of the set (if the set is an array,
  1.2936 +i.e. a set of sets);
  1.2937 +\item[\hspace*{54pt}] {\it record}, \dots, {\it record} are data
  1.2938 +records.
  1.2939 +\end{description}
  1.2940 +
  1.2941 +\begin{description}
  1.2942 +\item[{\rm Note:}\hspace*{31pt}] Commae preceding data records may be
  1.2943 +omitted.
  1.2944 +\end{description}
  1.2945 +
  1.2946 +\noindent Data records:
  1.2947 +
  1.2948 +\begin{description}
  1.2949 +\item[{\tt :=}\hspace*{45pt}] is a non-significant data record, which
  1.2950 +may be used freely to improve readability;
  1.2951 +\item[{\tt(} {\it slice} {\tt)}\hspace*{18.5pt}] specifies a slice;
  1.2952 +\item[{\it simple-data}\hspace*{5.5pt}] specifies set data in the
  1.2953 +simple format;
  1.2954 +\item[{\tt:} {\it matrix-data}]\hspace*{0pt}\\
  1.2955 +specifies set data in the matrix format;
  1.2956 +\item[{\tt(tr)} {\tt:} {\it matrix-data}]\hspace*{0pt}\\
  1.2957 +specifies set data in the transposed matrix format. (In this case the
  1.2958 +colon following the keyword {\tt(tr)} may be omitted.)
  1.2959 +\end{description}
  1.2960 +
  1.2961 +\noindent{\bf Examples}
  1.2962 +
  1.2963 +\begin{verbatim}
  1.2964 +set month := Jan Feb Mar Apr May Jun;
  1.2965 +set month "Jan", "Feb", "Mar", "Apr", "May", "Jun";
  1.2966 +set A[3,Mar] := (1,2) (2,3) (4,2) (3,1) (2,2) (4,4) (3,4);
  1.2967 +set A[3,'Mar'] := 1 2 2 3 4 2 3 1 2 2 4 4 2 4;
  1.2968 +set A[3,'Mar'] : 1 2 3 4 :=
  1.2969 +               1 - + - -
  1.2970 +               2 - + + -
  1.2971 +               3 + - - +
  1.2972 +               4 - + - + ;
  1.2973 +set B := (1,2,3) (1,3,2) (2,3,1) (2,1,3) (1,2,2) (1,1,1) (2,1,1);
  1.2974 +set B := (*,*,*) 1 2 3, 1 3 2, 2 3 1, 2 1 3, 1 2 2, 1 1 1, 2 1 1;
  1.2975 +set B := (1,*,2) 3 2 (2,*,1) 3 1 (1,2,3) (2,1,3) (1,1,1);
  1.2976 +set B := (1,*,*) : 1 2 3 :=
  1.2977 +                 1 + - -
  1.2978 +                 2 - + +
  1.2979 +                 3 - + -
  1.2980 +         (2,*,*) : 1 2 3 :=
  1.2981 +                 1 + - +
  1.2982 +                 2 - - -
  1.2983 +                 3 + - - ;
  1.2984 +\end{verbatim}
  1.2985 +
  1.2986 +\noindent(In these examples {\tt month} is a simple set of singlets,
  1.2987 +{\tt A} is a 2-dimensional array of doublets, and {\tt B} is a simple
  1.2988 +set of triplets. Data blocks for the same set are equivalent in the
  1.2989 +sense that they specify the same data in different formats.)
  1.2990 +
  1.2991 +\medskip
  1.2992 +
  1.2993 +The {\it set data block} is used to specify a complete elemental set,
  1.2994 +which is assigned to a set (if it is a simple set) or one of its
  1.2995 +members (if the set is an array of sets).\footnote{There is another way
  1.2996 +to specify data for a simple set along with data for parameters. This
  1.2997 +feature is discussed in the next subsection.}
  1.2998 +
  1.2999 +Data blocks can be specified only for non-computable sets, i.e. for
  1.3000 +sets, which have no assign ({\tt:=}) attribute in the corresponding set
  1.3001 +statements.
  1.3002 +
  1.3003 +If the set is a simple set, only its symbolic name should be specified
  1.3004 +in the header of the data block. Otherwise, if the set is a
  1.3005 +$n$-dimensional array, its symbolic name should be provided with a
  1.3006 +complete list of subscripts separated by commae and enclosed in square
  1.3007 +brackets to specify a particular member of the set array. The number of
  1.3008 +subscripts must be the same as the dimension of the set array, where
  1.3009 +each subscript must be a number or symbol.
  1.3010 +
  1.3011 +An elemental set defined in the set data block is coded as a sequence
  1.3012 +of data records described below.\footnote{{\it Data record} is simply a
  1.3013 +technical term. It does not mean that data records have any special
  1.3014 +formatting.}
  1.3015 +
  1.3016 +\newpage
  1.3017 +
  1.3018 +\subsubsection{Assign data record}
  1.3019 +
  1.3020 +The {\it assign} ({\tt:=}) {\it data record} is a non-signficant
  1.3021 +element. It may be used for improving readability of data blocks.
  1.3022 +
  1.3023 +\subsubsection{Slice data record}
  1.3024 +
  1.3025 +The {\it slice data record} is a control record, which specifies a
  1.3026 +{\it slice} of the elemental set defined in the data block. It has the
  1.3027 +following syntactic form:
  1.3028 +
  1.3029 +\medskip
  1.3030 +
  1.3031 +\noindent\hfil
  1.3032 +{\tt(} $s_1$ {\tt,} $s_2$ {\tt,} \dots {\tt,} $s_n$ {\tt)}
  1.3033 +
  1.3034 +\medskip
  1.3035 +
  1.3036 +\noindent where $s_1$, $s_2$, \dots, $s_n$ are components of the slice.
  1.3037 +
  1.3038 +Each component of the slice can be a number or symbol or the asterisk
  1.3039 +({\tt*}). The number of components in the slice must be the same as the
  1.3040 +dimension of $n$-tuples in the elemental set to be defined. For
  1.3041 +instance, if the elemental set contains 4-tuples (quadruplets), the
  1.3042 +slice must have four components. The number of asterisks in the slice
  1.3043 +is called the {\it slice dimension}.
  1.3044 +
  1.3045 +The effect of using slices is the following. If a $m$-dimensional slice
  1.3046 +(i.e. a slice having $m$ asterisks) is specified in the data block, all
  1.3047 +subsequent data records must specify tuples of the dimension $m$.
  1.3048 +Whenever a $m$-tuple is encountered, each asterisk in the slice is
  1.3049 +replaced by corresponding components of the $m$-tuple that gives the
  1.3050 +resultant $n$-tuple, which is included in the elemental set to be
  1.3051 +defined. For example, if the slice $(a,*,1,2,*)$ is in effect, and
  1.3052 +2-tuple $(3,b)$ is encountered in a subsequent data record, the
  1.3053 +resultant 5-tuple included in the elemental set is $(a,3,1,2,b)$.
  1.3054 +
  1.3055 +The slice having no asterisks itself defines a complete $n$-tuple,
  1.3056 +which is included in the elemental set.
  1.3057 +
  1.3058 +Being once specified the slice effects until either a new slice or the
  1.3059 +end of data block is encountered. Note that if no slice is specified in
  1.3060 +the data block, one, components of which are all asterisks, is assumed.
  1.3061 +
  1.3062 +\subsubsection{Simple data record}
  1.3063 +
  1.3064 +The {\it simple data record} defines one $n$-tuple in a simple format
  1.3065 +and has the following syntactic form:
  1.3066 +
  1.3067 +\medskip
  1.3068 +
  1.3069 +\noindent\hfil
  1.3070 +$t_1$ {\tt,} $t_2$ {\tt,} \dots {\tt,} $t_n$
  1.3071 +
  1.3072 +\medskip
  1.3073 +
  1.3074 +\noindent where $t_1$, $t_2$, \dots, $t_n$ are components of the
  1.3075 +$n$-tuple. Each component can be a number or symbol. Commae between
  1.3076 +components are optional and may be omitted.
  1.3077 +
  1.3078 +\subsubsection{Matrix data record}
  1.3079 +
  1.3080 +The {\it matrix data record} defines several 2-tuples (doublets) in
  1.3081 +a matrix format and has the following syntactic form:
  1.3082 +
  1.3083 +\newpage
  1.3084 +
  1.3085 +$$\begin{array}{cccccc}
  1.3086 +\mbox{{\tt:}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
  1.3087 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
  1.3088 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
  1.3089 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
  1.3090 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
  1.3091 +\end{array}$$
  1.3092 +where $r_1$, $r_2$, \dots, $r_m$ are numbers and/or symbols
  1.3093 +corresponding to rows of the matrix; $c_1$, $c_2$, \dots, $c_n$ are
  1.3094 +numbers and/or symbols corresponding to columns of the matrix, $a_{11}$,
  1.3095 +$a_{12}$, \dots, $a_{mn}$ are matrix elements, which can be either
  1.3096 +{\tt+} or {\tt-}. (In this data record the delimiter {\tt:} preceding
  1.3097 +the column list and the delimiter {\tt:=} following the column list
  1.3098 +cannot be omitted.)
  1.3099 +
  1.3100 +Each element $a_{ij}$ of the matrix data block (where $1\leq i\leq m$,
  1.3101 +$1\leq j\leq n$) corresponds to 2-tuple $(r_i,c_j)$. If $a_{ij}$ is the
  1.3102 +plus sign ({\tt+}), that 2-tuple (or a longer $n$-tuple, if a slice is
  1.3103 +used) is included in the elemental set. Otherwise, if $a_{ij}$ is the
  1.3104 +minus sign ({\tt-}), that 2-tuple is not included in the elemental set.
  1.3105 +
  1.3106 +Since the matrix data record defines 2-tuples, either the elemental set
  1.3107 +must consist of 2-tuples or the slice currently used must be
  1.3108 +2-dimensional.
  1.3109 +
  1.3110 +\subsubsection{Transposed matrix data record}
  1.3111 +
  1.3112 +The {\it transposed matrix data record} has the following syntactic
  1.3113 +form:
  1.3114 +$$\begin{array}{cccccc}
  1.3115 +\mbox{{\tt(tr) :}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
  1.3116 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
  1.3117 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
  1.3118 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
  1.3119 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
  1.3120 +\end{array}$$
  1.3121 +(In this case the delimiter {\tt:} following the keyword {\tt(tr)} is
  1.3122 +optional and may be omitted.)
  1.3123 +
  1.3124 +This data record is completely analogous to the matrix data record (see
  1.3125 +above) with only exception that in this case each element $a_{ij}$ of
  1.3126 +the matrix corresponds to 2-tuple $(c_j,r_i)$ rather than $(r_i,c_j)$.
  1.3127 +
  1.3128 +Being once specified the {\tt(tr)} indicator affects all subsequent
  1.3129 +data records until either a slice or the end of data block is
  1.3130 +encountered.
  1.3131 +
  1.3132 +\subsection{Parameter data block}
  1.3133 +
  1.3134 +\medskip
  1.3135 +
  1.3136 +\framebox[345pt][l]{
  1.3137 +\parbox[c][80pt]{345pt}{
  1.3138 +\hspace{6pt} {\tt param} {\it name} {\tt,} {\it record} {\tt,} \dots
  1.3139 +{\tt,} {\it record} {\tt;}
  1.3140 +
  1.3141 +\medskip
  1.3142 +
  1.3143 +\hspace{6pt} {\tt param} {\it name} {\tt default} {\it value} {\tt,}
  1.3144 +{\it record} {\tt,} \dots {\tt,} {\it record} {\tt;}
  1.3145 +
  1.3146 +\medskip
  1.3147 +
  1.3148 +\hspace{6pt} {\tt param} {\tt:} {\it tabbing-data} {\tt;}
  1.3149 +
  1.3150 +\medskip
  1.3151 +
  1.3152 +\hspace{6pt} {\tt param} {\tt default} {\it value} {\tt:}
  1.3153 +{\it tabbing-data} {\tt;}
  1.3154 +}}
  1.3155 +
  1.3156 +\newpage
  1.3157 +
  1.3158 +\setlength{\leftmargini}{60pt}
  1.3159 +
  1.3160 +\begin{description}
  1.3161 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
  1.3162 +parameter;
  1.3163 +\item[\hspace*{54pt}] {\it value} is an optional default value of the
  1.3164 +parameter;
  1.3165 +\item[\hspace*{54pt}] {\it record}, \dots, {\it record} are data
  1.3166 +records;
  1.3167 +\item[\hspace*{54pt}] {\it tabbing-data} specifies parameter data in
  1.3168 +the tabbing format.
  1.3169 +\end{description}
  1.3170 +
  1.3171 +\begin{description}
  1.3172 +\item[{\rm Note:}\hspace*{31pt}] Commae preceding data records may be
  1.3173 +omitted.
  1.3174 +\end{description}
  1.3175 +
  1.3176 +\noindent Data records:
  1.3177 +
  1.3178 +\begin{description}
  1.3179 +\item[{\tt :=}\hspace*{45pt}] is a non-significant data record, which
  1.3180 +may be used freely to improve readability;
  1.3181 +\item[{\tt[} {\it slice} {\tt]}\hspace*{18.5pt}] specifies a slice;
  1.3182 +\item[{\it plain-data}\hspace*{11pt}] specifies parameter data in the
  1.3183 +plain format;
  1.3184 +\item[{\tt:} {\it tabular-data}]\hspace*{0pt}\\
  1.3185 +specifies parameter data in the tabular format;
  1.3186 +\item[{\tt(tr)} {\tt:} {\it tabular-data}]\hspace*{0pt}\\
  1.3187 +specifies set data in the transposed tabular format. (In this case the
  1.3188 +colon following the keyword {\tt(tr)} may be omitted.)
  1.3189 +\end{description}
  1.3190 +
  1.3191 +\noindent{\bf Examples}
  1.3192 +
  1.3193 +\begin{verbatim}
  1.3194 +param T := 4;
  1.3195 +param month := 1 'Jan' 2 'Feb' 3 'Mar' 4 'Apr' 5 'May';
  1.3196 +param month := [1] Jan, [2] Feb, [3] Mar, [4] Apr, [5] May;
  1.3197 +param day := [Sun] 0, [Mon] 1, [Tue] 2, [Wed] 3, [Thu] 4,
  1.3198 +             [Fri] 5, [Sat] 6;
  1.3199 +param init_stock := iron 7.32 nickel 35.8;
  1.3200 +param init_stock [*] iron 7.32, nickel 35.8;
  1.3201 +param cost [iron] .025 [nickel] .03;
  1.3202 +param value := iron -.1, nickel .02;
  1.3203 +param       : init_stock cost value :=
  1.3204 +      iron       7.32    .025  -.1
  1.3205 +      nickel    35.8     .03    .02 ;
  1.3206 +param : raw : init_stock cost value :=
  1.3207 +      iron       7.32    .025  -.1
  1.3208 +      nickel    35.8     .03    .02 ;
  1.3209 +param demand default 0 (tr)
  1.3210 +       :  FRA  DET  LAN  WIN  STL  FRE  LAF :=
  1.3211 +   bands  300   .   100   75   .   225  250
  1.3212 +   coils  500  750  400  250   .   850  500
  1.3213 +   plate  100   .    .    50  200   .   250 ;
  1.3214 +\end{verbatim}
  1.3215 +
  1.3216 +\newpage
  1.3217 +
  1.3218 +\begin{verbatim}
  1.3219 +param trans_cost :=
  1.3220 +   [*,*,bands]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
  1.3221 +         GARY     30   10    8   10   11   71    6
  1.3222 +         CLEV     22    7   10    7   21   82   13
  1.3223 +         PITT     19   11   12   10   25   83   15
  1.3224 +   [*,*,coils]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
  1.3225 +         GARY     39   14   11   14   16   82    8
  1.3226 +         CLEV     27    9   12    9   26   95   17
  1.3227 +         PITT     24   14   17   13   28   99   20
  1.3228 +   [*,*,plate]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
  1.3229 +         GARY     41   15   12   16   17   86    8
  1.3230 +         CLEV     29    9   13    9   28   99   18
  1.3231 +         PITT     26   14   17   13   31  104   20 ;
  1.3232 +\end{verbatim}
  1.3233 +
  1.3234 +The {\it parameter data block} is used to specify complete data for a
  1.3235 +parameter (or parameters, if data are specified in the tabbing format).
  1.3236 +
  1.3237 +Data blocks can be specified only for non-computable parameters, i.e.
  1.3238 +for parameters, which have no assign ({\tt:=}) attribute in the
  1.3239 +corresponding parameter statements.
  1.3240 +
  1.3241 +Data defined in the parameter data block are coded as a sequence of
  1.3242 +data records described below. Additionally the data block can be
  1.3243 +provided with the optional {\tt default} attribute, which specifies a
  1.3244 +default numeric or symbolic value of the parameter (parameters). This
  1.3245 +default value is assigned to the parameter or its members, if
  1.3246 +no appropriate value is defined in the parameter data block. The
  1.3247 +{\tt default} attribute cannot be used, if it is already specified in
  1.3248 +the corresponding parameter statement.
  1.3249 +
  1.3250 +\subsubsection{Assign data record}
  1.3251 +
  1.3252 +The {\it assign} ({\tt:=}) {\it data record} is a non-signficant
  1.3253 +element. It may be used for improving readability of data blocks.
  1.3254 +
  1.3255 +\subsubsection{Slice data record}
  1.3256 +
  1.3257 +The {\it slice data record} is a control record, which specifies a
  1.3258 +{\it slice} of the parameter array. It has the following syntactic form:
  1.3259 +
  1.3260 +\medskip
  1.3261 +
  1.3262 +\noindent\hfil
  1.3263 +{\tt[} $s_1$ {\tt,} $s_2$ {\tt,} \dots {\tt,} $s_n$ {\tt]}
  1.3264 +
  1.3265 +\medskip
  1.3266 +
  1.3267 +\noindent where $s_1$, $s_2$, \dots, $s_n$ are components of the slice.
  1.3268 +
  1.3269 +Each component of the slice can be a number or symbol or the asterisk
  1.3270 +({\tt*}). The number of components in the slice must be the same as the
  1.3271 +dimension of the parameter. For instance, if the parameter is a
  1.3272 +4-dimensional array, the slice must have four components. The number of
  1.3273 +asterisks in the slice is called the {\it slice dimension}.
  1.3274 +
  1.3275 +The effect of using slices is the following. If a $m$-dimensional slice
  1.3276 +(i.e. a slice having $m$ asterisks) is specified in the data block, all
  1.3277 +subsequent data records must specify subscripts of the parameter
  1.3278 +members as if the parameter were $m$-dimensional, not $n$-dimensional.
  1.3279 +
  1.3280 +Whenever $m$ subscripts are encountered, each asterisk in the slice is
  1.3281 +replaced by corresponding subscript that gives $n$ subscripts, which
  1.3282 +define the actual parameter member. For example, if the slice
  1.3283 +$[a,*,1,2,*]$ is in effect, and subscripts 3 and $b$ are encountered in
  1.3284 +a subsequent data record, the complete subscript list used to choose a
  1.3285 +parameter member is $[a,3,1,2,b]$.
  1.3286 +
  1.3287 +It is allowed to specify a slice having no asterisks. Such slice itself
  1.3288 +defines a complete subscript list, in which case the next data record
  1.3289 +should define only a single value of corresponding parameter member.
  1.3290 +
  1.3291 +Being once specified the slice effects until either a new slice or the
  1.3292 +end of data block is encountered. Note that if no slice is specified in
  1.3293 +the data block, one, components of which are all asterisks, is assumed.
  1.3294 +
  1.3295 +\subsubsection{Plain data record}
  1.3296 +
  1.3297 +The {\it plain data record} defines a subscript list and a single value
  1.3298 +in the plain format. This record has the following syntactic form:
  1.3299 +
  1.3300 +\medskip
  1.3301 +
  1.3302 +\noindent\hfil
  1.3303 +$t_1$ {\tt,} $t_2$ {\tt,} \dots {\tt,} $t_n$ {\tt,} $v$
  1.3304 +
  1.3305 +\medskip
  1.3306 +
  1.3307 +\noindent where $t_1$, $t_2$, \dots, $t_n$ are subscripts, and $v$ is a
  1.3308 +value. Each subscript as well as the value can be a number or symbol.
  1.3309 +Commae following subscripts are optional and may be omitted.
  1.3310 +
  1.3311 +In case of 0-dimensional parameter or slice the plain data record has
  1.3312 +no subscripts and consists of a single value only.
  1.3313 +
  1.3314 +\subsubsection{Tabular data record}
  1.3315 +
  1.3316 +The {\it tabular data record} defines several values, where each value
  1.3317 +is provided with two subscripts. This record has the following
  1.3318 +syntactic form:
  1.3319 +$$\begin{array}{cccccc}
  1.3320 +\mbox{{\tt:}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
  1.3321 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
  1.3322 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
  1.3323 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
  1.3324 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
  1.3325 +\end{array}$$
  1.3326 +where $r_1$, $r_2$, \dots, $r_m$ are numbers and/or symbols
  1.3327 +corresponding to rows of the table; $c_1$, $c_2$, \dots, $c_n$ are
  1.3328 +numbers and/or symbols corresponding to columns of the table, $a_{11}$,
  1.3329 +$a_{12}$, \dots, $a_{mn}$ are table elements. Each element can be a
  1.3330 +number or symbol or the single decimal point ({\tt.}). (In this data
  1.3331 +record the delimiter {\tt:} preceding the column list and the delimiter
  1.3332 +{\tt:=} following the column list cannot be omitted.)
  1.3333 +
  1.3334 +Each element $a_{ij}$ of the tabular data block ($1\leq i\leq m$,
  1.3335 +$1\leq j\leq n$) defines two subscripts, where the first subscript is
  1.3336 +$r_i$, and the second one is $c_j$. These subscripts are used in
  1.3337 +conjunction with the current slice to form the complete subscript list
  1.3338 +that identifies a particular member of the parameter array. If $a_{ij}$
  1.3339 +is a number or symbol, this value is assigned to the parameter member.
  1.3340 +However, if $a_{ij}$ is the single decimal point, the member is
  1.3341 +assigned a default value specified either in the parameter data block
  1.3342 +or in the parameter statement, or, if no default value is specified,
  1.3343 +the member remains undefined.
  1.3344 +
  1.3345 +Since the tabular data record provides two subscripts for each value,
  1.3346 +either the parameter or the slice currently used must be 2-dimensional.
  1.3347 +
  1.3348 +\subsubsection{Transposed tabular data record}
  1.3349 +
  1.3350 +The {\it transposed tabular data record} has the following syntactic
  1.3351 +form:
  1.3352 +$$\begin{array}{cccccc}
  1.3353 +\mbox{{\tt(tr) :}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
  1.3354 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
  1.3355 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
  1.3356 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
  1.3357 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
  1.3358 +\end{array}$$
  1.3359 +(In this case the delimiter {\tt:} following the keyword {\tt(tr)} is
  1.3360 +optional and may be omitted.)
  1.3361 +
  1.3362 +This data record is completely analogous to the tabular data record
  1.3363 +(see above) with only exception that the first subscript defined by
  1.3364 +element $a_{ij}$ is $c_j$ while the second one is $r_i$.
  1.3365 +
  1.3366 +Being once specified the {\tt(tr)} indicator affects all subsequent
  1.3367 +data records until either a slice or the end of data block is
  1.3368 +encountered.
  1.3369 +
  1.3370 +\subsubsection{Tabbing data format}
  1.3371 +
  1.3372 +The parameter data block in the {\it tabbing format} has the following
  1.3373 +syntactic form:
  1.3374 +$$\begin{array}{p{12pt}@{\ }l@{\ }c@{\ }l@{\ }c@{\ }l@{\ }r@{\ }l@{\ }c
  1.3375 +@{\ }l@{\ }c@{\ }l@{\ }l}
  1.3376 +\multicolumn{7}{@{}c@{}}{\mbox{\tt param}\ \mbox{\tt default}\ \mbox
  1.3377 +{\it value}\ \mbox{\tt:}\ \mbox{\it s}\ \mbox{\tt:}}&
  1.3378 +p_1&\mbox{\tt,}&p_2&\mbox{\tt,} \dots \mbox{\tt,}&p_k&\mbox{\tt:=}\\
  1.3379 +&t_{11}&\mbox{\tt,}&t_{12}&\mbox{\tt,} \dots \mbox{\tt,}&t_{1n}&
  1.3380 +\mbox{\tt,}&a_{11}&\mbox{\tt,}&a_{12}&\mbox{\tt,} \dots \mbox{\tt,}&
  1.3381 +a_{1k}\\
  1.3382 +&t_{21}&\mbox{\tt,}&t_{22}&\mbox{\tt,} \dots \mbox{\tt,}&t_{2n}&
  1.3383 +\mbox{\tt,}&a_{21}&\mbox{\tt,}&a_{22}&\mbox{\tt,} \dots \mbox{\tt,}&
  1.3384 +a_{2k}\\
  1.3385 +\multicolumn{13}{c}
  1.3386 +{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  1.3387 +&t_{m1}&\mbox{\tt,}&t_{m2}&\mbox{\tt,} \dots \mbox{\tt,}&t_{mn}&
  1.3388 +\mbox{\tt,}&a_{m1}&\mbox{\tt,}&a_{m2}&\mbox{\tt,} \dots \mbox{\tt,}&
  1.3389 +a_{mk}&\mbox{\tt;}\\
  1.3390 +\end{array}$$
  1.3391 +
  1.3392 +{\it Notes:}
  1.3393 +
  1.3394 +1. The keyword {\tt default} may be omitted along with a value
  1.3395 +following it.
  1.3396 +
  1.3397 +2. Symbolic name {\tt s} may be omitted along with the colon following
  1.3398 +it.
  1.3399 +
  1.3400 +3. All comae are optional and may be omitted.
  1.3401 +
  1.3402 +\medskip
  1.3403 +
  1.3404 +The data block in the tabbing format shown above is exactly equivalent
  1.3405 +to the following data blocks for $j=1,2,\dots,k$:
  1.3406 +
  1.3407 +\medskip
  1.3408 +
  1.3409 +{\tt set} {\it s} {\tt:=}
  1.3410 +{\tt(}$t_{11}${\tt,}$t_{12}${\tt,}\dots{\tt,}$t_{1n}${\tt)}
  1.3411 +{\tt(}$t_{21}${\tt,}$t_{22}${\tt,}\dots{\tt,}$t_{2n}${\tt)} \dots
  1.3412 +{\tt(}$t_{m1}${\tt,}$t_{m2}${\tt,}\dots{\tt,}$t_{mn}${\tt)} {\tt;}
  1.3413 +
  1.3414 +{\tt param} $p_j$ {\tt default} {\it value} {\tt:=}
  1.3415 +
  1.3416 +$\!${\tt[}$t_{11}${\tt,}$t_{12}${\tt,}\dots{\tt,}$t_{1n}${\tt]}
  1.3417 +$a_{1j}$
  1.3418 +{\tt[}$t_{21}${\tt,}$t_{22}${\tt,}\dots{\tt,}$t_{2n}${\tt]} $a_{2j}$
  1.3419 +\dots
  1.3420 +{\tt[}$t_{m1}${\tt,}$t_{m2}${\tt,}\dots{\tt,}$t_{mn}${\tt]} $a_{mj}$
  1.3421 +{\tt;}
  1.3422 +
  1.3423 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.3424 +
  1.3425 +\appendix
  1.3426 +
  1.3427 +\newpage
  1.3428 +
  1.3429 +\section{Using suffixes}
  1.3430 +
  1.3431 +Suffixes can be used to retrieve additional values associated with
  1.3432 +model variables, constraints, and objectives.
  1.3433 +
  1.3434 +A {\it suffix} consists of a period ({\tt.}) followed by a non-reserved
  1.3435 +keyword. For example, if {\tt x} is a two-dimensional variable,
  1.3436 +{\tt x[i,j].lb} is a numeric value equal to the lower bound of
  1.3437 +elemental variable {\tt x[i,j]}, which (value) can be used everywhere
  1.3438 +in expressions like a numeric parameter.
  1.3439 +
  1.3440 +For model variables suffixes have the following meaning:
  1.3441 +
  1.3442 +\medskip
  1.3443 +
  1.3444 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  1.3445 +{\tt.lb}&lower bound\\
  1.3446 +{\tt.ub}&upper bound\\
  1.3447 +{\tt.status}&status in the solution:\\
  1.3448 +&0 --- undefined\\
  1.3449 +&1 --- basic\\
  1.3450 +&2 --- non-basic on lower bound\\
  1.3451 +&3 --- non-basic on upper bound\\
  1.3452 +&4 --- non-basic free (unbounded) variable\\
  1.3453 +&5 --- non-basic fixed variable\\
  1.3454 +{\tt.val}&primal value in the solution\\
  1.3455 +{\tt.dual}&dual value (reduced cost) in the solution\\
  1.3456 +\end{tabular}
  1.3457 +
  1.3458 +\medskip
  1.3459 +
  1.3460 +For model constraints and objectives suffixes have the following
  1.3461 +meaning:
  1.3462 +
  1.3463 +\medskip
  1.3464 +
  1.3465 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  1.3466 +{\tt.lb}&lower bound of the linear form\\
  1.3467 +{\tt.ub}&upper bound of the linear form\\
  1.3468 +{\tt.status}&status in the solution:\\
  1.3469 +&0 --- undefined\\
  1.3470 +&1 --- non-active\\
  1.3471 +&2 --- active on lower bound\\
  1.3472 +&3 --- active on upper bound\\
  1.3473 +&4 --- active free (unbounded) row\\
  1.3474 +&5 --- active equality constraint\\
  1.3475 +{\tt.val}&primal value of the linear form in the solution\\
  1.3476 +{\tt.dual}&dual value (reduced cost) of the linear form in the
  1.3477 +solution\\
  1.3478 +\end{tabular}
  1.3479 +
  1.3480 +\medskip
  1.3481 +
  1.3482 +Note that suffixes {\tt.status}, {\tt.val}, and {\tt.dual} can be used
  1.3483 +only below the solve statement.
  1.3484 +
  1.3485 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.3486 +
  1.3487 +\newpage
  1.3488 +
  1.3489 +\section{Date and time functions}
  1.3490 +
  1.3491 +\noindent\hfil
  1.3492 +by Andrew Makhorin \verb|<mao@gnu.org>|
  1.3493 +
  1.3494 +\noindent\hfil
  1.3495 +and Heinrich Schuchardt \verb|<heinrich.schuchardt@gmx.de>|
  1.3496 +
  1.3497 +\subsection{Obtaining current calendar time}
  1.3498 +\label{gmtime}
  1.3499 +
  1.3500 +To obtain the current calendar time in MathProg there exists the
  1.3501 +function {\tt gmtime}. It has no arguments and returns the number of
  1.3502 +seconds elapsed since 00:00:00 on January 1, 1970, Coordinated
  1.3503 +Universal Time (UTC). For example:
  1.3504 +
  1.3505 +\medskip
  1.3506 +
  1.3507 +\verb|   param utc := gmtime();|
  1.3508 +
  1.3509 +\medskip
  1.3510 +
  1.3511 +MathProg has no function to convert UTC time returned by the function
  1.3512 +{\tt gmtime} to {\it local} calendar times. Thus, if you need to
  1.3513 +determine the current local calendar time, you have to add to the UTC
  1.3514 +time returned the time offset from UTC expressed in seconds. For
  1.3515 +example, the time in Berlin during the winter is one hour ahead of UTC
  1.3516 +that corresponds to the time offset +1 hour = +3600 secs, so the
  1.3517 +current winter calendar time in Berlin may be determined as follows:
  1.3518 +
  1.3519 +\medskip
  1.3520 +
  1.3521 +\verb|   param now := gmtime() + 3600;|
  1.3522 +
  1.3523 +\medskip
  1.3524 +
  1.3525 +\noindent Similarly, the summer time in Chicago (Central Daylight Time)
  1.3526 +is five hours behind UTC, so the corresponding current local calendar
  1.3527 +time may be determined as follows:
  1.3528 +
  1.3529 +\medskip
  1.3530 +
  1.3531 +\verb|   param now := gmtime() - 5 * 3600;|
  1.3532 +
  1.3533 +\medskip
  1.3534 +
  1.3535 +Note that the value returned by {\tt gmtime} is volatile, i.e. being
  1.3536 +called several times this function may return different values.
  1.3537 +
  1.3538 +\subsection{Converting character string to calendar time}
  1.3539 +\label{str2time}
  1.3540 +
  1.3541 +The function {\tt str2time(}{\it s}{\tt,} {\it f}{\tt)} converts a
  1.3542 +character string (timestamp) specified by its first argument {\it s},
  1.3543 +which must be a symbolic expression, to the calendar time suitable for
  1.3544 +arithmetic calculations. The conversion is controlled by the specified
  1.3545 +format string {\it f} (the second argument), which also must be a
  1.3546 +symbolic expression.
  1.3547 +
  1.3548 +The result of conversion returned by {\tt str2time} has the same
  1.3549 +meaning as values returned by the function {\tt gmtime} (see Subsection
  1.3550 +\ref{gmtime}, page \pageref{gmtime}). Note that {\tt str2time} does
  1.3551 +{\tt not} correct the calendar time returned for the local timezone,
  1.3552 +i.e. being applied to 00:00:00 on January 1, 1970 it always returns 0.
  1.3553 +
  1.3554 +For example, the model statements:
  1.3555 +
  1.3556 +\medskip
  1.3557 +
  1.3558 +\verb|   param s, symbolic, := "07/14/98 13:47";|
  1.3559 +
  1.3560 +\verb|   param t := str2time(s, "%m/%d/%y %H:%M");|
  1.3561 +
  1.3562 +\verb|   display t;|
  1.3563 +
  1.3564 +\medskip
  1.3565 +
  1.3566 +\noindent produce the following printout:
  1.3567 +
  1.3568 +\medskip
  1.3569 +
  1.3570 +\verb|   t = 900424020|
  1.3571 +
  1.3572 +\medskip
  1.3573 +
  1.3574 +\noindent where the calendar time printed corresponds to 13:47:00 on
  1.3575 +July 14, 1998.
  1.3576 +
  1.3577 +\newpage
  1.3578 +
  1.3579 +The format string passed to the function {\tt str2time} consists of
  1.3580 +conversion specifiers and ordinary characters. Each conversion
  1.3581 +specifier begins with a percent ({\tt\%}) character followed by a
  1.3582 +letter.
  1.3583 +
  1.3584 +The following conversion specifiers may be used in the format string:
  1.3585 +
  1.3586 +\medskip
  1.3587 +
  1.3588 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3589 +{\tt\%b}&The abbreviated month name (case insensitive). At least three
  1.3590 +first letters of the month name must appear in the input string.\\
  1.3591 +\end{tabular}
  1.3592 +
  1.3593 +\medskip
  1.3594 +
  1.3595 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3596 +{\tt\%d}&The day of the month as a decimal number (range 1 to 31).
  1.3597 +Leading zero is permitted, but not required.\\
  1.3598 +\end{tabular}
  1.3599 +
  1.3600 +\medskip
  1.3601 +
  1.3602 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3603 +{\tt\%h}&The same as {\tt\%b}.\\
  1.3604 +\end{tabular}
  1.3605 +
  1.3606 +\medskip
  1.3607 +
  1.3608 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3609 +{\tt\%H}&The hour as a decimal number, using a 24-hour clock (range 0
  1.3610 +to 23). Leading zero is permitted, but not required.\\
  1.3611 +\end{tabular}
  1.3612 +
  1.3613 +\medskip
  1.3614 +
  1.3615 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3616 +{\tt\%m}&The month as a decimal number (range 1 to 12). Leading zero is
  1.3617 +permitted, but not required.\\
  1.3618 +\end{tabular}
  1.3619 +
  1.3620 +\medskip
  1.3621 +
  1.3622 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3623 +{\tt\%M}&The minute as a decimal number (range 0 to 59). Leading zero
  1.3624 +is permitted, but not required.\\
  1.3625 +\end{tabular}
  1.3626 +
  1.3627 +\medskip
  1.3628 +
  1.3629 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3630 +{\tt\%S}&The second as a decimal number (range 0 to 60). Leading zero
  1.3631 +is permitted, but not required.\\
  1.3632 +\end{tabular}
  1.3633 +
  1.3634 +\medskip
  1.3635 +
  1.3636 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3637 +{\tt\%y}&The year without a century as a decimal number (range 0 to 99).
  1.3638 +Leading zero is permitted, but not required. Input values in the range
  1.3639 +0 to 68 are considered as the years 2000 to 2068 while the values 69 to
  1.3640 +99 as the years 1969 to 1999.\\
  1.3641 +\end{tabular}
  1.3642 +
  1.3643 +\medskip
  1.3644 +
  1.3645 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3646 +{\tt\%z}&The offset from GMT in ISO 8601 format.\\
  1.3647 +\end{tabular}
  1.3648 +
  1.3649 +\medskip
  1.3650 +
  1.3651 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3652 +{\tt\%\%}&A literal {\tt\%} character.\\
  1.3653 +\end{tabular}
  1.3654 +
  1.3655 +\medskip
  1.3656 +
  1.3657 +All other (ordinary) characters in the format string must have a
  1.3658 +matching character in the input string to be converted. Exceptions are
  1.3659 +spaces in the input string which can match zero or more space
  1.3660 +characters in the format string.
  1.3661 +
  1.3662 +If some date and/or time component(s) are missing in the format and,
  1.3663 +therefore, in the input string, the function {\tt str2time} uses their
  1.3664 +default values corresponding to 00:00:00 on January 1, 1970, that is,
  1.3665 +the default value of the year is 1970, the default value of the month
  1.3666 +is January, etc.
  1.3667 +
  1.3668 +The function {\tt str2time} is applicable to all calendar times in the
  1.3669 +range 00:00:00 on January 1, 0001 to 23:59:59 on December 31, 4000 of
  1.3670 +the Gregorian calendar.
  1.3671 +
  1.3672 +\subsection{Converting calendar time to character string}
  1.3673 +\label{time2str}
  1.3674 +
  1.3675 +The function {\tt time2str(}{\it t}{\tt,} {\it f}{\tt)} converts the
  1.3676 +calendar time specified by its first argument {\it t}, which must be a
  1.3677 +numeric expression, to a character string (symbolic value). The
  1.3678 +conversion is controlled by the specified format string {\it f} (the
  1.3679 +second argument), which must be a symbolic expression.
  1.3680 +
  1.3681 +The calendar time passed to {\tt time2str} has the same meaning as
  1.3682 +values returned by the function {\tt gmtime} (see Subsection
  1.3683 +\ref{gmtime}, page \pageref{gmtime}). Note that {\tt time2str} does
  1.3684 +{\it not} correct the specified calendar time for the local timezone,
  1.3685 +i.e. the calendar time 0 always corresponds to 00:00:00 on January 1,
  1.3686 +1970.
  1.3687 +
  1.3688 +For example, the model statements:
  1.3689 +
  1.3690 +\medskip
  1.3691 +
  1.3692 +\verb|   param s, symbolic, := time2str(gmtime(), "%FT%TZ");|
  1.3693 +
  1.3694 +\verb|   display s;|
  1.3695 +
  1.3696 +\medskip
  1.3697 +
  1.3698 +\noindent may produce the following printout:
  1.3699 +
  1.3700 +\medskip
  1.3701 +
  1.3702 +\verb|   s = '2008-12-04T00:23:45Z'|
  1.3703 +
  1.3704 +\medskip
  1.3705 +
  1.3706 +\noindent which is a timestamp in the ISO format.
  1.3707 +
  1.3708 +The format string passed to the function {\tt time2str} consists of
  1.3709 +conversion specifiers and ordinary characters. Each conversion
  1.3710 +specifier begins with a percent ({\tt\%}) character followed by a
  1.3711 +letter.
  1.3712 +
  1.3713 +The following conversion specifiers may be used in the format string:
  1.3714 +
  1.3715 +\medskip
  1.3716 +
  1.3717 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3718 +{\tt\%a}&The abbreviated (2-character) weekday name.\\
  1.3719 +\end{tabular}
  1.3720 +
  1.3721 +\medskip
  1.3722 +
  1.3723 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3724 +{\tt\%A}&The full weekday name.\\
  1.3725 +\end{tabular}
  1.3726 +
  1.3727 +\medskip
  1.3728 +
  1.3729 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3730 +{\tt\%b}&The abbreviated (3-character) month name.\\
  1.3731 +\end{tabular}
  1.3732 +
  1.3733 +\medskip
  1.3734 +
  1.3735 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3736 +{\tt\%B}&The full month name.\\
  1.3737 +\end{tabular}
  1.3738 +
  1.3739 +\medskip
  1.3740 +
  1.3741 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3742 +{\tt\%C}&The century of the year, that is the greatest integer not
  1.3743 +greater than the year divided by 100.\\
  1.3744 +\end{tabular}
  1.3745 +
  1.3746 +\medskip
  1.3747 +
  1.3748 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3749 +{\tt\%d}&The day of the month as a decimal number (range 01 to 31).\\
  1.3750 +\end{tabular}
  1.3751 +
  1.3752 +\medskip
  1.3753 +
  1.3754 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3755 +{\tt\%D}&The date using the format \verb|%m/%d/%y|.\\
  1.3756 +\end{tabular}
  1.3757 +
  1.3758 +\medskip
  1.3759 +
  1.3760 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3761 +{\tt\%e}&The day of the month like with \verb|%d|, but padded with
  1.3762 +blank rather than zero.\\
  1.3763 +\end{tabular}
  1.3764 +
  1.3765 +\medskip
  1.3766 +
  1.3767 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3768 +{\tt\%F}&The date using the format \verb|%Y-%m-%d|.\\
  1.3769 +\end{tabular}
  1.3770 +
  1.3771 +\medskip
  1.3772 +
  1.3773 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3774 +{\tt\%g}&The year corresponding to the ISO week number, but without the
  1.3775 +century (range 00 to 99). This has the same format and value as
  1.3776 +\verb|%y|, except that if the ISO week number (see \verb|%V|) belongs
  1.3777 +to the previous or next year, that year is used instead.\\
  1.3778 +\end{tabular}
  1.3779 +
  1.3780 +\medskip
  1.3781 +
  1.3782 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3783 +{\tt\%G}&The year corresponding to the ISO week number. This has the
  1.3784 +same format and value as \verb|%Y|, except that if the ISO week number
  1.3785 +(see \verb|%V|) belongs to the previous or next year, that year is used
  1.3786 +instead.
  1.3787 +\end{tabular}
  1.3788 +
  1.3789 +\medskip
  1.3790 +
  1.3791 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3792 +{\tt\%h}&The same as \verb|%b|.\\
  1.3793 +\end{tabular}
  1.3794 +
  1.3795 +\medskip
  1.3796 +
  1.3797 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3798 +{\tt\%H}&The hour as a decimal number, using a 24-hour clock (range 00
  1.3799 +to 23).\\
  1.3800 +\end{tabular}
  1.3801 +
  1.3802 +\medskip
  1.3803 +
  1.3804 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3805 +{\tt\%I}&The hour as a decimal number, using a 12-hour clock (range 01
  1.3806 +to 12).\\
  1.3807 +\end{tabular}
  1.3808 +
  1.3809 +\medskip
  1.3810 +
  1.3811 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3812 +{\tt\%j}&The day of the year as a decimal number (range 001 to 366).\\
  1.3813 +\end{tabular}
  1.3814 +
  1.3815 +\medskip
  1.3816 +
  1.3817 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3818 +{\tt\%k}&The hour as a decimal number, using a 24-hour clock like
  1.3819 +\verb|%H|, but padded with blank rather than zero.\\
  1.3820 +\end{tabular}
  1.3821 +
  1.3822 +\medskip
  1.3823 +
  1.3824 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3825 +{\tt\%l}&The hour as a decimal number, using a 12-hour clock like
  1.3826 +\verb|%I|, but padded with blank rather than zero.
  1.3827 +\end{tabular}
  1.3828 +
  1.3829 +\medskip
  1.3830 +
  1.3831 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3832 +{\tt\%m}&The month as a decimal number (range 01 to 12).\\
  1.3833 +\end{tabular}
  1.3834 +
  1.3835 +\medskip
  1.3836 +
  1.3837 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3838 +{\tt\%M}&The minute as a decimal number (range 00 to 59).\\
  1.3839 +\end{tabular}
  1.3840 +
  1.3841 +\medskip
  1.3842 +
  1.3843 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3844 +{\tt\%p}&Either {\tt AM} or {\tt PM}, according to the given time value.
  1.3845 +Midnight is treated as {\tt AM} and noon as {\tt PM}.\\
  1.3846 +\end{tabular}
  1.3847 +
  1.3848 +\medskip
  1.3849 +
  1.3850 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3851 +{\tt\%P}&Either {\tt am} or {\tt pm}, according to the given time value.
  1.3852 +Midnight is treated as {\tt am} and noon as {\tt pm}.\\
  1.3853 +\end{tabular}
  1.3854 +
  1.3855 +\medskip
  1.3856 +
  1.3857 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3858 +{\tt\%R}&The hour and minute in decimal numbers using the format
  1.3859 +\verb|%H:%M|.\\
  1.3860 +\end{tabular}
  1.3861 +
  1.3862 +\medskip
  1.3863 +
  1.3864 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3865 +{\tt\%S}&The second as a decimal number (range 00 to 59).\\
  1.3866 +\end{tabular}
  1.3867 +
  1.3868 +\medskip
  1.3869 +
  1.3870 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3871 +{\tt\%T}&The time of day in decimal numbers using the format
  1.3872 +\verb|%H:%M:%S|.\\
  1.3873 +\end{tabular}
  1.3874 +
  1.3875 +\medskip
  1.3876 +
  1.3877 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3878 +{\tt\%u}&The day of the week as a decimal number (range 1 to 7), Monday
  1.3879 +being 1.\\
  1.3880 +\end{tabular}
  1.3881 +
  1.3882 +\medskip
  1.3883 +
  1.3884 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3885 +{\tt\%U}&The week number of the current year as a decimal number (range
  1.3886 +00 to 53), starting with the first Sunday as the first day of the first
  1.3887 +week. Days preceding the first Sunday in the year are considered to be
  1.3888 +in week 00.
  1.3889 +\end{tabular}
  1.3890 +
  1.3891 +\medskip
  1.3892 +
  1.3893 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3894 +{\tt\%V}&The ISO week number as a decimal number (range 01 to 53). ISO
  1.3895 +weeks start with Monday and end with Sunday. Week 01 of a year is the
  1.3896 +first week which has the majority of its days in that year; this is
  1.3897 +equivalent to the week containing January 4. Week 01 of a year can
  1.3898 +contain days from the previous year. The week before week 01 of a year
  1.3899 +is the last week (52 or 53) of the previous year even if it contains
  1.3900 +days from the new year. In other word, if 1 January is Monday, Tuesday,
  1.3901 +Wednesday or Thursday, it is in week 01; if 1 January is Friday,
  1.3902 +Saturday or Sunday, it is in week 52 or 53 of the previous year.\\
  1.3903 +\end{tabular}
  1.3904 +
  1.3905 +\medskip
  1.3906 +
  1.3907 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3908 +{\tt\%w}&The day of the week as a decimal number (range 0 to 6), Sunday
  1.3909 +being 0.\\
  1.3910 +\end{tabular}
  1.3911 +
  1.3912 +\medskip
  1.3913 +
  1.3914 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3915 +{\tt\%W}&The week number of the current year as a decimal number (range
  1.3916 +00 to 53), starting with the first Monday as the first day of the first
  1.3917 +week. Days preceding the first Monday in the year are considered to be
  1.3918 +in week 00.\\
  1.3919 +\end{tabular}
  1.3920 +
  1.3921 +\medskip
  1.3922 +
  1.3923 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3924 +{\tt\%y}&The year without a century as a decimal number (range 00 to
  1.3925 +99), that is the year modulo 100.\\
  1.3926 +\end{tabular}
  1.3927 +
  1.3928 +\medskip
  1.3929 +
  1.3930 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3931 +{\tt\%Y}&The year as a decimal number, using the Gregorian calendar.\\
  1.3932 +\end{tabular}
  1.3933 +
  1.3934 +\medskip
  1.3935 +
  1.3936 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
  1.3937 +{\tt\%\%}&A literal \verb|%| character.\\
  1.3938 +\end{tabular}
  1.3939 +
  1.3940 +\medskip
  1.3941 +
  1.3942 +All other (ordinary) characters in the format string are simply copied
  1.3943 +to the resultant string.
  1.3944 +
  1.3945 +The first argument (calendar time) passed to the function {\tt time2str}
  1.3946 +must be in the range from $-62135596800$ to $+64092211199$ that
  1.3947 +corresponds to the period from 00:00:00 on January 1, 0001 to 23:59:59
  1.3948 +on December 31, 4000 of the Gregorian calendar.
  1.3949 +
  1.3950 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.3951 +
  1.3952 +\newpage
  1.3953 +
  1.3954 +\section{Table drivers}
  1.3955 +\label{drivers}
  1.3956 +
  1.3957 +\noindent\hfil
  1.3958 +by Andrew Makhorin \verb|<mao@gnu.org>|
  1.3959 +
  1.3960 +\noindent\hfil
  1.3961 +and Heinrich Schuchardt \verb|<heinrich.schuchardt@gmx.de>|
  1.3962 +
  1.3963 +\bigskip\bigskip
  1.3964 +
  1.3965 +The {\it table driver} is a program module which provides transmitting
  1.3966 +data between MathProg model objects and data tables.
  1.3967 +
  1.3968 +Currently the GLPK package has four table drivers:
  1.3969 +
  1.3970 +\setlength{\leftmargini}{2.5em}
  1.3971 +
  1.3972 +\begin{itemize}
  1.3973 +\item built-in CSV table driver;
  1.3974 +\item built-in xBASE table driver;
  1.3975 +\item ODBC table driver;
  1.3976 +\item MySQL table driver.
  1.3977 +\end{itemize}
  1.3978 +
  1.3979 +\subsection{CSV table driver}
  1.3980 +
  1.3981 +The CSV table driver assumes that the data table is represented in the
  1.3982 +form of a plain text file in the CSV (comma-separated values) file
  1.3983 +format as described below.
  1.3984 +
  1.3985 +To choose the CSV table driver its name in the table statement should
  1.3986 +be specified as \verb|"CSV"|, and the only argument should specify the
  1.3987 +name of a plain text file containing the table. For example:
  1.3988 +
  1.3989 +\medskip
  1.3990 +
  1.3991 +\verb|   table data IN "CSV" "data.csv": ... ;|
  1.3992 +
  1.3993 +\medskip
  1.3994 +
  1.3995 +The filename suffix may be arbitrary, however, it is recommended to use
  1.3996 +the suffix `\verb|.csv|'.
  1.3997 +
  1.3998 +On reading input tables the CSV table driver provides an implicit field
  1.3999 +named \verb|RECNO|, which contains the current record number. This
  1.4000 +field can be specified in the input table statement as if there were
  1.4001 +the actual field having the name \verb|RECNO| in the CSV file. For
  1.4002 +example:
  1.4003 +
  1.4004 +\medskip
  1.4005 +
  1.4006 +\verb|   table list IN "CSV" "list.csv": num <- [RECNO], ... ;|
  1.4007 +
  1.4008 +\subsubsection*{CSV format\footnote{This material is based on the RFC
  1.4009 +document 4180.}}
  1.4010 +
  1.4011 +The CSV (comma-separated values) format is a plain text file format
  1.4012 +defined as follows.
  1.4013 +
  1.4014 +1. Each record is located on a separate line, delimited by a line
  1.4015 +break. For example:
  1.4016 +
  1.4017 +\medskip
  1.4018 +
  1.4019 +\verb|   aaa,bbb,ccc\n|
  1.4020 +
  1.4021 +\verb|   xxx,yyy,zzz\n|
  1.4022 +
  1.4023 +\medskip
  1.4024 +
  1.4025 +\noindent
  1.4026 +where \verb|\n| means the control character \verb|LF| ({\tt 0x0A}).
  1.4027 +
  1.4028 +\newpage
  1.4029 +
  1.4030 +2. The last record in the file may or may not have an ending line
  1.4031 +break. For example:
  1.4032 +
  1.4033 +\medskip
  1.4034 +
  1.4035 +\verb|   aaa,bbb,ccc\n|
  1.4036 +
  1.4037 +\verb|   xxx,yyy,zzz|
  1.4038 +
  1.4039 +\medskip
  1.4040 +
  1.4041 +3. There should be a header line appearing as the first line of the
  1.4042 +file in the same format as normal record lines. This header should
  1.4043 +contain names corresponding to the fields in the file. The number of
  1.4044 +field names in the header line should be the same as the number of
  1.4045 +fields in the records of the file. For example:
  1.4046 +
  1.4047 +\medskip
  1.4048 +
  1.4049 +\verb|   name1,name2,name3\n|
  1.4050 +
  1.4051 +\verb|   aaa,bbb,ccc\n|
  1.4052 +
  1.4053 +\verb|   xxx,yyy,zzz\n|
  1.4054 +
  1.4055 +\medskip
  1.4056 +
  1.4057 +4. Within the header and each record there may be one or more fields
  1.4058 +separated by commas. Each line should contain the same number of fields
  1.4059 +throughout the file. Spaces are considered as part of a field and
  1.4060 +therefore not ignored. The last field in the record should not be
  1.4061 +followed by a comma. For example:
  1.4062 +
  1.4063 +\medskip
  1.4064 +
  1.4065 +\verb|   aaa,bbb,ccc\n|
  1.4066 +
  1.4067 +\medskip
  1.4068 +
  1.4069 +5. Fields may or may not be enclosed in double quotes. For example:
  1.4070 +
  1.4071 +\medskip
  1.4072 +
  1.4073 +\verb|   "aaa","bbb","ccc"\n|
  1.4074 +
  1.4075 +\verb|   zzz,yyy,xxx\n|
  1.4076 +
  1.4077 +\medskip
  1.4078 +
  1.4079 +6. If a field is enclosed in double quotes, each double quote which is
  1.4080 +part of the field should be coded twice. For example:
  1.4081 +
  1.4082 +\medskip
  1.4083 +
  1.4084 +\verb|   "aaa","b""bb","ccc"\n|
  1.4085 +
  1.4086 +\medskip
  1.4087 +
  1.4088 +\noindent{\bf Example}
  1.4089 +
  1.4090 +\begin{verbatim}
  1.4091 +FROM,TO,DISTANCE,COST
  1.4092 +Seattle,New-York,2.5,0.12
  1.4093 +Seattle,Chicago,1.7,0.08
  1.4094 +Seattle,Topeka,1.8,0.09
  1.4095 +San-Diego,New-York,2.5,0.15
  1.4096 +San-Diego,Chicago,1.8,0.10
  1.4097 +San-Diego,Topeka,1.4,0.07
  1.4098 +\end{verbatim}
  1.4099 +
  1.4100 +\subsection{xBASE table driver}
  1.4101 +
  1.4102 +The xBASE table driver assumes that the data table is stored in the
  1.4103 +.dbf file format.
  1.4104 +
  1.4105 +To choose the xBASE table driver its name in the table statement should
  1.4106 +be specified as \verb|"xBASE"|, and the first argument should specify
  1.4107 +the name of a .dbf file containing the table. For the output table there
  1.4108 +should be the second argument defining the table format in the form
  1.4109 +\verb|"FF...F"|, where \verb|F| is either {\tt C({\it n})},
  1.4110 +which specifies a character field of length $n$, or
  1.4111 +{\tt N({\it n}{\rm [},{\it p}{\rm ]})}, which specifies a numeric field
  1.4112 +of length $n$ and precision $p$ (by default $p$ is 0).
  1.4113 +
  1.4114 +The following is a simple example which illustrates creating and
  1.4115 +reading a .dbf file:
  1.4116 +
  1.4117 +\begin{verbatim}
  1.4118 +table tab1{i in 1..10} OUT "xBASE" "foo.dbf"
  1.4119 +   "N(5)N(10,4)C(1)C(10)": 2*i+1 ~ B, Uniform(-20,+20) ~ A,
  1.4120 +   "?" ~ FOO, "[" & i & "]" ~ C;
  1.4121 +set S, dimen 4;
  1.4122 +table tab2 IN "xBASE" "foo.dbf": S <- [B, C, RECNO, A];
  1.4123 +display S;
  1.4124 +end;
  1.4125 +\end{verbatim}
  1.4126 +
  1.4127 +\subsection{ODBC table driver}
  1.4128 +
  1.4129 +The ODBC table driver allows connecting to SQL databases using an
  1.4130 +implementation of the ODBC interface based on the Call Level Interface
  1.4131 +(CLI).\footnote{The corresponding software standard is defined in
  1.4132 +ISO/IEC 9075-3:2003.}
  1.4133 +
  1.4134 +\paragraph{Debian GNU/Linux.}
  1.4135 +Under Debian GNU/Linux the ODBC table driver uses the iODBC
  1.4136 +package,\footnote{See {\tt<http://www.iodbc.org/>}.} which should be
  1.4137 +installed before building the GLPK package. The installation can be
  1.4138 +effected with the following command:
  1.4139 +
  1.4140 +\begin{verbatim}
  1.4141 +sudo apt-get install libiodbc2-dev
  1.4142 +\end{verbatim}
  1.4143 +
  1.4144 +Note that on configuring the GLPK package to enable using the iODBC
  1.4145 +library the option `\verb|--enable-odbc|' should be passed to the
  1.4146 +configure script.
  1.4147 +
  1.4148 +The individual databases must be entered for systemwide usage in
  1.4149 +\linebreak \verb|/etc/odbc.ini| and \verb|/etc/odbcinst.ini|. Database
  1.4150 +connections to be used by a single user are specified by files in the
  1.4151 +home directory (\verb|.odbc.ini| and \verb|.odbcinst.ini|).
  1.4152 +
  1.4153 +\paragraph{Microsoft Windows.}
  1.4154 +Under Microsoft Windows the ODBC table driver uses the Microsoft ODBC
  1.4155 +library. To enable this feature the symbol:
  1.4156 +
  1.4157 +\begin{verbatim}
  1.4158 +#define ODBC_DLNAME "odbc32.dll"
  1.4159 +\end{verbatim}
  1.4160 +
  1.4161 +\noindent
  1.4162 +should be defined in the GLPK configuration file `\verb|config.h|'.
  1.4163 +
  1.4164 +Data sources can be created via the Administrative Tools from the
  1.4165 +Control Panel.
  1.4166 +
  1.4167 +\bigskip
  1.4168 +
  1.4169 +To choose the ODBC table driver its name in the table statement should
  1.4170 +be specified as \verb|'ODBC'| or \verb|'iODBC'|.
  1.4171 +
  1.4172 +The argument list is specified as follows.
  1.4173 +
  1.4174 +The first argument is the connection string passed to the ODBC library,
  1.4175 +for example:
  1.4176 +
  1.4177 +\verb|'DSN=glpk;UID=user;PWD=password'|, or
  1.4178 +
  1.4179 +\verb|'DRIVER=MySQL;DATABASE=glpkdb;UID=user;PWD=password'|.
  1.4180 +
  1.4181 +Different parts of the string are separated by semicolons. Each part
  1.4182 +consists of a pair {\it fieldname} and {\it value} separated by the
  1.4183 +equal sign. Allowable fieldnames depend on the ODBC library. Typically
  1.4184 +the following fieldnames are allowed:
  1.4185 +
  1.4186 +\verb|DATABASE | database;
  1.4187 +
  1.4188 +\verb|DRIVER   | ODBC driver;
  1.4189 +
  1.4190 +\verb|DSN      | name of a data source;
  1.4191 +
  1.4192 +\verb|FILEDSN  | name of a file data source;
  1.4193 +
  1.4194 +\verb|PWD      | user password;
  1.4195 +
  1.4196 +\verb|SERVER   | database;
  1.4197 +
  1.4198 +\verb|UID      | user name.
  1.4199 +
  1.4200 +The second argument and all following are considered to be SQL
  1.4201 +statements
  1.4202 +
  1.4203 +SQL statements may be spread over multiple arguments.  If the last
  1.4204 +character of an argument is a semicolon this indicates the end of
  1.4205 +a SQL statement.
  1.4206 +
  1.4207 +The arguments of a SQL statement are concatenated separated by space.
  1.4208 +The eventual trailing semicolon will be removed.
  1.4209 +
  1.4210 +All but the last SQL statement will be executed directly.
  1.4211 +
  1.4212 +For IN-table the last SQL statement can be a SELECT command starting
  1.4213 +with the capitalized letters \verb|'SELECT '|. If the string does not
  1.4214 +start with \verb|'SELECT '| it is considered to be a table name and a
  1.4215 +SELECT statement is automatically generated.
  1.4216 +
  1.4217 +For OUT-table the last SQL statement can contain one or multiple
  1.4218 +question marks. If it contains a question mark it is considered a
  1.4219 +template for the write routine. Otherwise the string is considered a
  1.4220 +table name and an INSERT template is automatically generated.
  1.4221 +
  1.4222 +The writing routine uses the template with the question marks and
  1.4223 +replaces the first question mark by the first output parameter, the
  1.4224 +second question mark by the second output parameter and so forth. Then
  1.4225 +the SQL command is issued.
  1.4226 +
  1.4227 +The following is an example of the output table statement:
  1.4228 +
  1.4229 +\begin{small}
  1.4230 +\begin{verbatim}
  1.4231 +table ta { l in LOCATIONS } OUT
  1.4232 +   'ODBC'
  1.4233 +   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
  1.4234 +   'DROP TABLE IF EXISTS result;'
  1.4235 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
  1.4236 +   'INSERT INTO result 'VALUES ( 4, ?, ? )' :
  1.4237 +   l ~ LOC, quantity[l] ~ QUAN;
  1.4238 +\end{verbatim}
  1.4239 +\end{small}
  1.4240 +
  1.4241 +\noindent
  1.4242 +Alternatively it could be written as follows:
  1.4243 +
  1.4244 +\begin{small}
  1.4245 +\begin{verbatim}
  1.4246 +table ta { l in LOCATIONS } OUT
  1.4247 +   'ODBC'
  1.4248 +   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
  1.4249 +   'DROP TABLE IF EXISTS result;'
  1.4250 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
  1.4251 +   'result' :
  1.4252 +   l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;
  1.4253 +\end{verbatim}
  1.4254 +\end{small}
  1.4255 +
  1.4256 +Using templates with `\verb|?|' supports not only INSERT, but also
  1.4257 +UPDATE, DELETE, etc. For example:
  1.4258 +
  1.4259 +\begin{small}
  1.4260 +\begin{verbatim}
  1.4261 +table ta { l in LOCATIONS } OUT
  1.4262 +   'ODBC'
  1.4263 +   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
  1.4264 +   'UPDATE result SET DATE = ' & date & ' WHERE ID = 4;'
  1.4265 +   'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :
  1.4266 +   quantity[l], l;
  1.4267 +\end{verbatim}
  1.4268 +\end{small}
  1.4269 +
  1.4270 +\subsection{MySQL table driver}
  1.4271 +
  1.4272 +The MySQL table driver allows connecting to MySQL databases.
  1.4273 +
  1.4274 +\paragraph{Debian GNU/Linux.}
  1.4275 +Under Debian GNU/Linux the MySQL table\linebreak driver uses the MySQL
  1.4276 +package,\footnote{For download development files see
  1.4277 +{\tt<http://dev.mysql.com/downloads/mysql/>}.} which should be installed
  1.4278 +before building the GLPK package. The installation can be effected with
  1.4279 +the following command:
  1.4280 +
  1.4281 +\begin{verbatim}
  1.4282 +sudo apt-get install libmysqlclient15-dev
  1.4283 +\end{verbatim}
  1.4284 +
  1.4285 +Note that on configuring the GLPK package to enable using the MySQL
  1.4286 +library the option `\verb|--enable-mysql|' should be passed to the
  1.4287 +configure script.
  1.4288 +
  1.4289 +\paragraph{Microsoft Windows.}
  1.4290 +Under Microsoft Windows the MySQL table driver also uses the MySQL
  1.4291 +library. To enable this feature the symbol:
  1.4292 +
  1.4293 +\begin{verbatim}
  1.4294 +#define MYSQL_DLNAME "libmysql.dll"
  1.4295 +\end{verbatim}
  1.4296 +
  1.4297 +\noindent
  1.4298 +should be defined in the GLPK configuration file `\verb|config.h|'.
  1.4299 +
  1.4300 +\bigskip
  1.4301 +
  1.4302 +To choose the MySQL table driver its name in the table statement should
  1.4303 +be specified as \verb|'MySQL'|.
  1.4304 +
  1.4305 +The argument list is specified as follows.
  1.4306 +
  1.4307 +The first argument specifies how to connect the data base in the DSN
  1.4308 +style, for example:
  1.4309 +
  1.4310 +\verb|'Database=glpk;UID=glpk;PWD=gnu'|.
  1.4311 +
  1.4312 +Different parts of the string are separated by semicolons. Each part
  1.4313 +consists of a pair {\it fieldname} and {\it value} separated by the
  1.4314 +equal sign. The following fieldnames are allowed:
  1.4315 +
  1.4316 +\verb|Server   | server running the database (defaulting to localhost);
  1.4317 +
  1.4318 +\verb|Database | name of the database;
  1.4319 +
  1.4320 +\verb|UID      | user name;
  1.4321 +
  1.4322 +\verb|PWD      | user password;
  1.4323 +
  1.4324 +\verb|Port     | port used by the server (defaulting to 3306).
  1.4325 +
  1.4326 +The second argument and all following are considered to be SQL
  1.4327 +statements
  1.4328 +
  1.4329 +SQL statements may be spread over multiple arguments.  If the last
  1.4330 +character of an argument is a semicolon this indicates the end of
  1.4331 +a SQL statement.
  1.4332 +
  1.4333 +The arguments of a SQL statement are concatenated separated by space.
  1.4334 +The eventual trailing semicolon will be removed.
  1.4335 +
  1.4336 +All but the last SQL statement will be executed directly.
  1.4337 +
  1.4338 +For IN-table the last SQL statement can be a SELECT command starting
  1.4339 +with the capitalized letters \verb|'SELECT '|. If the string does not
  1.4340 +start with \verb|'SELECT '| it is considered to be a table name and a
  1.4341 +SELECT statement is automatically generated.
  1.4342 +
  1.4343 +For OUT-table the last SQL statement can contain one or multiple
  1.4344 +question marks. If it contains a question mark it is considered a
  1.4345 +template for the write routine. Otherwise the string is considered a
  1.4346 +table name and an INSERT template is automatically generated.
  1.4347 +
  1.4348 +The writing routine uses the template with the question marks and
  1.4349 +replaces the first question mark by the first output parameter, the
  1.4350 +second question mark by the second output parameter and so forth. Then
  1.4351 +the SQL command is issued.
  1.4352 +
  1.4353 +The following is an example of the output table statement:
  1.4354 +
  1.4355 +\begin{small}
  1.4356 +\begin{verbatim}
  1.4357 +table ta { l in LOCATIONS } OUT
  1.4358 +   'MySQL'
  1.4359 +   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
  1.4360 +   'DROP TABLE IF EXISTS result;'
  1.4361 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
  1.4362 +   'INSERT INTO result VALUES ( 4, ?, ? )' :
  1.4363 +   l ~ LOC, quantity[l] ~ QUAN;
  1.4364 +\end{verbatim}
  1.4365 +\end{small}
  1.4366 +
  1.4367 +\noindent
  1.4368 +Alternatively it could be written as follows:
  1.4369 +
  1.4370 +\begin{small}
  1.4371 +\begin{verbatim}
  1.4372 +table ta { l in LOCATIONS } OUT
  1.4373 +   'MySQL'
  1.4374 +   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
  1.4375 +   'DROP TABLE IF EXISTS result;'
  1.4376 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
  1.4377 +   'result' :
  1.4378 +   l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;
  1.4379 +\end{verbatim}
  1.4380 +\end{small}
  1.4381 +
  1.4382 +Using templates with `\verb|?|' supports not only INSERT, but also
  1.4383 +UPDATE, DELETE, etc. For example:
  1.4384 +
  1.4385 +\begin{small}
  1.4386 +\begin{verbatim}
  1.4387 +table ta { l in LOCATIONS } OUT
  1.4388 +   'MySQL'
  1.4389 +   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
  1.4390 +   'UPDATE result SET DATE = ' & date & ' WHERE ID = 4;'
  1.4391 +   'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :
  1.4392 +   quantity[l], l;
  1.4393 +\end{verbatim}
  1.4394 +\end{small}
  1.4395 +
  1.4396 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.4397 +
  1.4398 +\newpage
  1.4399 +
  1.4400 +\section{Solving models with glpsol}
  1.4401 +
  1.4402 +The GLPK package\footnote{{\tt http://www.gnu.org/software/glpk/}}
  1.4403 +includes the program {\tt glpsol}, which is a stand-alone LP/MIP solver.
  1.4404 +This program can be launched from the command line or from the shell to
  1.4405 +solve models written in the GNU MathProg modeling language.
  1.4406 +
  1.4407 +In order to tell the solver that the input file contains a model
  1.4408 +description, you need to specify the option \verb|--model| in the
  1.4409 +command line. For example:
  1.4410 +
  1.4411 +\medskip
  1.4412 +
  1.4413 +\verb|   glpsol --model foo.mod|
  1.4414 +
  1.4415 +\medskip
  1.4416 +
  1.4417 +Sometimes it is necessary to use the data section placed in a separate
  1.4418 +file, in which case you may use the following command:
  1.4419 +
  1.4420 +\medskip
  1.4421 +
  1.4422 +\verb|   glpsol --model foo.mod --data foo.dat|
  1.4423 +
  1.4424 +\medskip
  1.4425 +
  1.4426 +\noindent Note that if the model file also contains the data section,
  1.4427 +that section is ignored.
  1.4428 +
  1.4429 +If the model description contains some display and/or printf statements,
  1.4430 +by default the output is sent to the terminal. In order to redirect the
  1.4431 +output to a file you may use the following command:
  1.4432 +
  1.4433 +\medskip
  1.4434 +
  1.4435 +\verb|   glpsol --model foo.mod --display foo.out|
  1.4436 +
  1.4437 +\medskip
  1.4438 +
  1.4439 +If you need to look at the problem, which has been generated by the
  1.4440 +model translator, you may use the option \verb|--wlp| as follows:
  1.4441 +
  1.4442 +\medskip
  1.4443 +
  1.4444 +\verb|   glpsol --model foo.mod --wlp foo.lp|
  1.4445 +
  1.4446 +\medskip
  1.4447 +
  1.4448 +\noindent in which case the problem data is written to file
  1.4449 +\verb|foo.lp| in CPLEX LP format suitable for visual analysis.
  1.4450 +
  1.4451 +Sometimes it is needed merely to check the model description not
  1.4452 +solving the generated problem instance. In this case you may specify
  1.4453 +the option \verb|--check|, for example:
  1.4454 +
  1.4455 +\medskip
  1.4456 +
  1.4457 +\verb|   glpsol --check --model foo.mod --wlp foo.lp|
  1.4458 +
  1.4459 +\medskip
  1.4460 +
  1.4461 +In order to write a numeric solution obtained by the solver you may use
  1.4462 +the following command:
  1.4463 +
  1.4464 +\medskip
  1.4465 +
  1.4466 +\verb|   glpsol --model foo.mod --output foo.sol|
  1.4467 +
  1.4468 +\medskip
  1.4469 +
  1.4470 +\noindent in which case the solution is written to file \verb|foo.sol|
  1.4471 +in a plain text format.
  1.4472 +
  1.4473 +The complete list of the \verb|glpsol| options can be found in the
  1.4474 +reference manual included in the GLPK distribution.
  1.4475 +
  1.4476 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.4477 +
  1.4478 +\newpage
  1.4479 +
  1.4480 +\section{Example model description}
  1.4481 +
  1.4482 +\subsection{Model description written in MathProg}
  1.4483 +
  1.4484 +Below here is a complete example of the model description written in
  1.4485 +the GNU MathProg modeling language.
  1.4486 +
  1.4487 +\begin{small}
  1.4488 +\begin{verbatim}
  1.4489 +# A TRANSPORTATION PROBLEM
  1.4490 +#
  1.4491 +# This problem finds a least cost shipping schedule that meets
  1.4492 +# requirements at markets and supplies at factories.
  1.4493 +#
  1.4494 +#  References:
  1.4495 +#              Dantzig G B, "Linear Programming and Extensions."
  1.4496 +#              Princeton University Press, Princeton, New Jersey, 1963,
  1.4497 +#              Chapter 3-3.
  1.4498 +
  1.4499 +set I;
  1.4500 +/* canning plants */
  1.4501 +
  1.4502 +set J;
  1.4503 +/* markets */
  1.4504 +
  1.4505 +param a{i in I};
  1.4506 +/* capacity of plant i in cases */
  1.4507 +
  1.4508 +param b{j in J};
  1.4509 +/* demand at market j in cases */
  1.4510 +
  1.4511 +param d{i in I, j in J};
  1.4512 +/* distance in thousands of miles */
  1.4513 +
  1.4514 +param f;
  1.4515 +/* freight in dollars per case per thousand miles */
  1.4516 +
  1.4517 +param c{i in I, j in J} := f * d[i,j] / 1000;
  1.4518 +/* transport cost in thousands of dollars per case */
  1.4519 +
  1.4520 +var x{i in I, j in J} >= 0;
  1.4521 +/* shipment quantities in cases */
  1.4522 +
  1.4523 +minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
  1.4524 +/* total transportation costs in thousands of dollars */
  1.4525 +
  1.4526 +s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
  1.4527 +/* observe supply limit at plant i */
  1.4528 +
  1.4529 +s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
  1.4530 +/* satisfy demand at market j */
  1.4531 +
  1.4532 +data;
  1.4533 +
  1.4534 +set I := Seattle San-Diego;
  1.4535 +
  1.4536 +set J := New-York Chicago Topeka;
  1.4537 +
  1.4538 +param a := Seattle     350
  1.4539 +           San-Diego   600;
  1.4540 +
  1.4541 +param b := New-York    325
  1.4542 +           Chicago     300
  1.4543 +           Topeka      275;
  1.4544 +
  1.4545 +param d :              New-York   Chicago   Topeka :=
  1.4546 +           Seattle     2.5        1.7       1.8
  1.4547 +           San-Diego   2.5        1.8       1.4  ;
  1.4548 +
  1.4549 +param f := 90;
  1.4550 +
  1.4551 +end;
  1.4552 +\end{verbatim}
  1.4553 +\end{small}
  1.4554 +
  1.4555 +\subsection{Generated LP problem instance}
  1.4556 +
  1.4557 +Below here is the result of the translation of the example model
  1.4558 +produced by the solver \verb|glpsol| and written in CPLEX LP format
  1.4559 +with the option \verb|--wlp|.
  1.4560 +
  1.4561 +\begin{small}
  1.4562 +\begin{verbatim}
  1.4563 +\* Problem: transp *\
  1.4564 +
  1.4565 +Minimize
  1.4566 + cost: + 0.225 x(Seattle,New~York) + 0.153 x(Seattle,Chicago)
  1.4567 + + 0.162 x(Seattle,Topeka) + 0.225 x(San~Diego,New~York)
  1.4568 + + 0.162 x(San~Diego,Chicago) + 0.126 x(San~Diego,Topeka)
  1.4569 +
  1.4570 +Subject To
  1.4571 + supply(Seattle): + x(Seattle,New~York) + x(Seattle,Chicago)
  1.4572 + + x(Seattle,Topeka) <= 350
  1.4573 + supply(San~Diego): + x(San~Diego,New~York) + x(San~Diego,Chicago)
  1.4574 + + x(San~Diego,Topeka) <= 600
  1.4575 + demand(New~York): + x(Seattle,New~York) + x(San~Diego,New~York) >= 325
  1.4576 + demand(Chicago): + x(Seattle,Chicago) + x(San~Diego,Chicago) >= 300
  1.4577 + demand(Topeka): + x(Seattle,Topeka) + x(San~Diego,Topeka) >= 275
  1.4578 +
  1.4579 +End
  1.4580 +\end{verbatim}
  1.4581 +\end{small}
  1.4582 +
  1.4583 +\subsection{Optimal LP solution}
  1.4584 +
  1.4585 +Below here is the optimal solution of the generated LP problem instance
  1.4586 +found by the solver \verb|glpsol| and written in plain text format
  1.4587 +with the option \verb|--output|.
  1.4588 +
  1.4589 +\newpage
  1.4590 +
  1.4591 +\begin{small}
  1.4592 +\begin{verbatim}
  1.4593 +Problem:    transp
  1.4594 +Rows:       6
  1.4595 +Columns:    6
  1.4596 +Non-zeros:  18
  1.4597 +Status:     OPTIMAL
  1.4598 +Objective:  cost = 153.675 (MINimum)
  1.4599 +
  1.4600 +No.   Row name   St   Activity    Lower bound  Upper bound   Marginal
  1.4601 +--- ------------ -- ------------ ------------ ------------ ------------
  1.4602 +  1 cost         B       153.675
  1.4603 +  2 supply[Seattle]
  1.4604 +                 B           300                       350
  1.4605 +  3 supply[San-Diego]
  1.4606 +                 NU          600                       600        < eps
  1.4607 +  4 demand[New-York]
  1.4608 +                 NL          325          325                     0.225
  1.4609 +  5 demand[Chicago]
  1.4610 +                 NL          300          300                     0.153
  1.4611 +  6 demand[Topeka]
  1.4612 +                 NL          275          275                     0.126
  1.4613 +
  1.4614 +No. Column name  St   Activity    Lower bound  Upper bound   Marginal
  1.4615 +--- ------------ -- ------------ ------------ ------------ ------------
  1.4616 +  1 x[Seattle,New-York]
  1.4617 +                 B             0            0
  1.4618 +  2 x[Seattle,Chicago]
  1.4619 +                 B           300            0
  1.4620 +  3 x[Seattle,Topeka]
  1.4621 +                 NL            0            0                     0.036
  1.4622 +  4 x[San-Diego,New-York]
  1.4623 +                 B           325            0
  1.4624 +  5 x[San-Diego,Chicago]
  1.4625 +                 NL            0            0                     0.009
  1.4626 +  6 x[San-Diego,Topeka]
  1.4627 +                 B           275            0
  1.4628 +
  1.4629 +End of output
  1.4630 +\end{verbatim}
  1.4631 +\end{small}
  1.4632 +
  1.4633 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1.4634 +
  1.4635 +\newpage
  1.4636 +
  1.4637 +\setcounter{secnumdepth}{-1}
  1.4638 +
  1.4639 +\section{Acknowledgment}
  1.4640 +
  1.4641 +The authors would like to thank the following people, who kindly read,
  1.4642 +commented, and corrected the draft of this document:
  1.4643 +
  1.4644 +\medskip
  1.4645 +
  1.4646 +\noindent Juan Carlos Borras \verb|<borras@cs.helsinki.fi>|
  1.4647 +
  1.4648 +\medskip
  1.4649 +
  1.4650 +\noindent Harley Mackenzie \verb|<hjm@bigpond.com>|
  1.4651 +
  1.4652 +\medskip
  1.4653 +
  1.4654 +\noindent Robbie Morrison \verb|<robbie@actrix.co.nz>|
  1.4655 +
  1.4656 +\end{document}