
alpar@9: %* gmpl.tex *%
alpar@9: 
alpar@9: %***********************************************************************
alpar@9: %  This code is part of GLPK (GNU Linear Programming Kit).
alpar@9: %
alpar@9: %  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
alpar@9: %  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
alpar@9: %  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
alpar@9: %  E-mail: <mao@gnu.org>.
alpar@9: %
alpar@9: %  GLPK is free software: you can redistribute it and/or modify it
alpar@9: %  under the terms of the GNU General Public License as published by
alpar@9: %  the Free Software Foundation, either version 3 of the License, or
alpar@9: %  (at your option) any later version.
alpar@9: %
alpar@9: %  GLPK is distributed in the hope that it will be useful, but WITHOUT
alpar@9: %  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
alpar@9: %  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
alpar@9: %  License for more details.
alpar@9: %
alpar@9: %  You should have received a copy of the GNU General Public License
alpar@9: %  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
alpar@9: %***********************************************************************
alpar@9: 
alpar@9: \documentclass[10pt]{article}
alpar@9: \usepackage[dvipdfm,linktocpage,colorlinks,linkcolor=blue]{hyperref}
alpar@9: 
alpar@9: \begin{document}
alpar@9: 
alpar@9: \thispagestyle{empty}
alpar@9: 
alpar@9: \begin{center}
alpar@9: 
alpar@9: \vspace*{1in}
alpar@9: 
alpar@9: \begin{huge}
alpar@9: \sf\bfseries Modeling Language GNU MathProg
alpar@9: \end{huge}
alpar@9: 
alpar@9: \vspace{0.5in}
alpar@9: 
alpar@9: \begin{LARGE}
alpar@9: \sf Language Reference
alpar@9: \end{LARGE}
alpar@9: 
alpar@9: \vspace{0.5in}
alpar@9: 
alpar@9: \begin{LARGE}
alpar@9: \sf for GLPK Version 4.45
alpar@9: \end{LARGE}
alpar@9: 
alpar@9: \vspace{0.5in}
alpar@9: \begin{Large}
alpar@9: \sf (DRAFT, December 2010)
alpar@9: \end{Large}
alpar@9: 
alpar@9: \end{center}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \vspace*{1in}
alpar@9: 
alpar@9: \vfill
alpar@9: 
alpar@9: \noindent
alpar@9: The GLPK package is part of the GNU Project released under the aegis of
alpar@9: GNU.
alpar@9: 
alpar@9: \medskip\noindent
alpar@9: Copyright \copyright{} 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
alpar@9: 2008, 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
alpar@9: Moscow Aviation Institute, Moscow, Russia. All rights reserved.
alpar@9: 
alpar@9: \medskip\noindent
alpar@9: Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
alpar@9: MA 02110-1301, USA.
alpar@9: 
alpar@9: \medskip\noindent
alpar@9: Permission is granted to make and distribute verbatim copies of this
alpar@9: manual provided the copyright notice and this permission notice are
alpar@9: preserved on all copies.
alpar@9: 
alpar@9: \medskip\noindent
alpar@9: Permission is granted to copy and distribute modified versions of this
alpar@9: manual under the conditions for verbatim copying, provided also that
alpar@9: the entire resulting derived work is distributed under the terms of
alpar@9: a permission notice identical to this one.
alpar@9: 
alpar@9: \medskip\noindent
alpar@9: Permission is granted to copy and distribute translations of this
alpar@9: manual into another language, under the above conditions for modified
alpar@9: versions.
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \tableofcontents
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Introduction}
alpar@9: 
alpar@9: {\it GNU MathProg} is a modeling language intended for describing
alpar@9: linear mathematical programming models.\footnote{The GNU MathProg
alpar@9: language is a subset of the AMPL language. Its GLPK implementation is
alpar@9: mainly based on the paper: {\it Robert Fourer}, {\it David M. Gay}, and
alpar@9: {\it Brian W. Kernighan}, ``A Modeling Language for Mathematical
alpar@9: Programming.'' {\it Management Science} 36 (1990)\linebreak pp. 519-54.}
alpar@9: 
alpar@9: Model descriptions written in the GNU MathProg language consist of
alpar@9: a set of statements and data blocks constructed by the user from the
alpar@9: language elements described in this document.
alpar@9: 
alpar@9: In a process called {\it translation}, a program called the {\it model
alpar@9: translator} analyzes the model description and translates it into
alpar@9: internal data structures, which may be then used either for generating
alpar@9: mathematical programming problem instance or directly by a program
alpar@9: called the {\it solver} to obtain numeric solution of the problem.
alpar@9: 
alpar@9: \subsection{Linear programming problem}
alpar@9: \label{problem}
alpar@9: 
alpar@9: In MathProg the linear programming (LP) problem is stated as follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{.7in}minimize (or maximize)
alpar@9: $$z=c_1x_1+c_2x_2+\dots+c_nx_n+c_0\eqno(1.1)$$
alpar@9: \noindent\hspace{.7in}subject to linear constraints
alpar@9: $$
alpar@9: \begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }l}
alpar@9: L_1&\leq&a_{11}x_1&+&a_{12}x_2&+\dots+&a_{1n}x_n&\leq&U_1\\
alpar@9: L_2&\leq&a_{21}x_1&+&a_{22}x_2&+\dots+&a_{2n}x_n&\leq&U_2\\
alpar@9: \multicolumn{9}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
alpar@9: L_m&\leq&a_{m1}x_1&+&a_{m2}x_2&+\dots+&a_{mn}x_n&\leq&U_m\\
alpar@9: \end{array}\eqno(1.2)
alpar@9: $$
alpar@9: \noindent\hspace{.7in}and bounds of variables
alpar@9: $$
alpar@9: \begin{array}{l@{\ }c@{\ }c@{\ }c@{\ }l}
alpar@9: l_1&\leq&x_1&\leq&u_1\\
alpar@9: l_2&\leq&x_2&\leq&u_2\\
alpar@9: \multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .}\\
alpar@9: l_n&\leq&x_n&\leq&u_n\\
alpar@9: \end{array}\eqno(1.3)
alpar@9: $$
alpar@9: where $x_1$, $x_2$, \dots, $x_n$ are variables; $z$ is the objective
alpar@9: function; $c_1$, $c_2$, \dots, $c_n$ are objective coefficients; $c_0$
alpar@9: is the constant term (``shift'') of the objective function; $a_{11}$,
alpar@9: $a_{12}$, \dots, $a_{mn}$ are constraint coefficients; $L_1$, $L_2$,
alpar@9: \dots, $L_m$ are lower constraint bounds; $U_1$, $U_2$, \dots, $U_m$
alpar@9: are upper constraint bounds; $l_1$, $l_2$, \dots, $l_n$ are lower
alpar@9: bounds of variables; $u_1$, $u_2$, \dots, $u_n$ are upper bounds of
alpar@9: variables.
alpar@9: 
alpar@9: Bounds of variables and constraint bounds can be finite as well as
alpar@9: infinite. Besides, lower bounds can be equal to corresponding upper
alpar@9: bounds. Thus, the following types of variables and constraints are
alpar@9: allowed:
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \begin{tabular}{@{}r@{\ }c@{\ }c@{\ }c@{\ }l@{\hspace*{38pt}}l}
alpar@9: $-\infty$&$<$&$x$&$<$&$+\infty$&Free (unbounded) variable\\
alpar@9: $l$&$\leq$&$x$&$<$&$+\infty$&Variable with lower bound\\
alpar@9: $-\infty$&$<$&$x$&$\leq$&$u$&Variable with upper bound\\
alpar@9: $l$&$\leq$&$x$&$\leq$&$u$&Double-bounded variable\\
alpar@9: $l$&$=$&$x$&=&$u$&Fixed variable\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: \begin{tabular}{@{}r@{\ }c@{\ }c@{\ }c@{\ }ll}
alpar@9: $-\infty$&$<$&$\sum a_jx_j$&$<$&$+\infty$&Free (unbounded) linear
alpar@9: form\\
alpar@9: $L$&$\leq$&$\sum a_jx_j$&$<$&$+\infty$&Inequality constraint ``greater
alpar@9: than or equal to''\\
alpar@9: $-\infty$&$<$&$\sum a_jx_j$&$\leq$&$U$&Inequality constraint ``less
alpar@9: than or equal to''\\
alpar@9: $L$&$\leq$&$\sum a_jx_j$&$\leq$&$U$&Double-bounded inequality
alpar@9: constraint\\
alpar@9: $L$&$=$&$\sum a_jx_j$&=&$U$&Equality constraint\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: In addition to pure LP problems MathProg also allows mixed integer
alpar@9: linear programming (MIP) problems, where some or all variables are
alpar@9: restricted to be integer or binary.
alpar@9: 
alpar@9: \subsection{Model objects}
alpar@9: 
alpar@9: In MathProg the model is described in terms of sets, parameters,
alpar@9: variables, constraints, and objectives, which are called {\it model
alpar@9: objects}.
alpar@9: 
alpar@9: The user introduces particular model objects using the language
alpar@9: statements. Each model object is provided with a symbolic name that
alpar@9: uniquely identifies the object and is intended for referencing purposes.
alpar@9: 
alpar@9: Model objects, including sets, can be multidimensional arrays built
alpar@9: over indexing sets. Formally, $n$-dimensional array $A$ is the mapping:
alpar@9: $$A:\Delta\rightarrow\Xi,\eqno(1.4)$$
alpar@9: where $\Delta\subseteq S_1\times\dots\times S_n$ is a subset of the
alpar@9: Cartesian product of indexing sets,\linebreak $\Xi$ is a set of array members.
alpar@9: In MathProg the set $\Delta$ is called the {\it subscript domain}. Its
alpar@9: members are $n$-tuples $(i_1,\dots,i_n)$, where $i_1\in S_1$, \dots,
alpar@9: $i_n\in S_n$.
alpar@9: 
alpar@9: If $n=0$, the Cartesian product above has exactly one member (namely,
alpar@9: \linebreak 0-tuple), so it is convenient to think scalar objects as
alpar@9: 0-dimensional arrays having one member.
alpar@9: 
alpar@9: The type of array members is determined by the type of corresponding
alpar@9: model object as follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: Model object&Array member\\
alpar@9: \hline
alpar@9: Set&Elemental plain set\\
alpar@9: Parameter&Number or symbol\\
alpar@9: Variable&Elemental variable\\
alpar@9: Constraint&Elemental constraint\\
alpar@9: Objective&Elemental objective\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: In order to refer to a particular object member the object should be
alpar@9: provided with {\it subscripts}. For example, if $a$ is a 2-dimensional
alpar@9: parameter defined over $I\times J$, a reference to its particular
alpar@9: member can be written as $a[i,j]$, where $i\in I$ and $j\in J$. It is
alpar@9: understood that scalar objects being 0-dimensional need no subscripts.
alpar@9: 
alpar@9: \subsection{Structure of model description}
alpar@9: 
alpar@9: It is sometimes desirable to write a model which, at various points,
alpar@9: may require different data for each problem instance to be solved using
alpar@9: that model. For this reason in MathProg the model description consists
alpar@9: of two parts: the {\it model section} and the {\it data section}.
alpar@9: 
alpar@9: The model section is a main part of the model description that contains
alpar@9: declarations of model objects and is common for all problems based on
alpar@9: the corresponding model.
alpar@9: 
alpar@9: The data section is an optional part of the model description that
alpar@9: contains data specific for a particular problem instance.
alpar@9: 
alpar@9: Depending on what is more convenient the model and data sections can be
alpar@9: placed either in one file or in two separate files. The latter feature
alpar@9: allows having arbitrary number of different data sections to be used
alpar@9: with the same model section.
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Coding model description}
alpar@9: \label{coding}
alpar@9: 
alpar@9: The model description is coded in plain text format using ASCII
alpar@9: character set. Characters valid in the model description are the
alpar@9: following:
alpar@9: 
alpar@9: \begin{itemize}
alpar@9: \item alphabetic characters:\\
alpar@9: \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|\\
alpar@9: \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 _|
alpar@9: \item numeric characters:\\
alpar@9: \verb|0 1 2 3 4 5 6 7 8 9|
alpar@9: \item special characters:\\
alpar@9: \verb?! " # & ' ( ) * + , - . / : ; < = > [ ] ^ { | }?
alpar@9: \item white-space characters:\\
alpar@9: \verb|SP HT CR NL VT FF|
alpar@9: \end{itemize}
alpar@9: 
alpar@9: Within string literals and comments any ASCII characters (except
alpar@9: control characters) are valid.
alpar@9: 
alpar@9: White-space characters are non-significant. They can be used freely
alpar@9: between lexical units to improve readability of the model description.
alpar@9: They are also used to separate lexical units from each other if there
alpar@9: is no other way to do that.
alpar@9: 
alpar@9: Syntactically model description is a sequence of lexical units in the
alpar@9: following categories:
alpar@9: 
alpar@9: \begin{itemize}
alpar@9: \item symbolic names;
alpar@9: \item numeric literals;
alpar@9: \item string literals;
alpar@9: \item keywords;
alpar@9: \item delimiters;
alpar@9: \item comments.
alpar@9: \end{itemize}
alpar@9: 
alpar@9: The lexical units of the language are discussed below.
alpar@9: 
alpar@9: \subsection{Symbolic names}
alpar@9: 
alpar@9: A {\it symbolic name} consists of alphabetic and numeric characters,
alpar@9: the first of which must be alphabetic. All symbolic names are distinct
alpar@9: (case sensitive).
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|alpha123|
alpar@9: 
alpar@9: \noindent\verb|This_is_a_name|
alpar@9: 
alpar@9: \noindent\verb|_P123_abc_321|
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: Symbolic names are used to identify model objects (sets, parameters,
alpar@9: variables, constraints, objectives) and dummy indices.
alpar@9: 
alpar@9: All symbolic names (except names of dummy indices) must be unique, i.e.
alpar@9: the model description must have no objects with identical names.
alpar@9: Symbolic names of dummy indices must be unique within the scope, where
alpar@9: they are valid.
alpar@9: 
alpar@9: \subsection{Numeric literals}
alpar@9: 
alpar@9: A {\it numeric literal} has the form {\it xx}{\tt E}{\it syy}, where
alpar@9: {\it xx} is a number with optional decimal point, {\it s} is the sign
alpar@9: {\tt+} or {\tt-}, {\it yy} is a decimal exponent. The letter {\tt E} is
alpar@9: case insensitive and can be coded as {\tt e}.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|123|
alpar@9: 
alpar@9: \noindent\verb|3.14159|
alpar@9: 
alpar@9: \noindent\verb|56.E+5|
alpar@9: 
alpar@9: \noindent\verb|.78|
alpar@9: 
alpar@9: \noindent\verb|123.456e-7|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Numeric literals are used to represent numeric quantities. They have
alpar@9: obvious fixed meaning.
alpar@9: 
alpar@9: \subsection{String literals}
alpar@9: 
alpar@9: A {\it string literal} is a sequence of arbitrary characters enclosed
alpar@9: either in single quotes or in double quotes. Both these forms are
alpar@9: equivalent.
alpar@9: 
alpar@9: If the single quote is part of a string literal enclosed in single
alpar@9: quotes, it must be coded twice. Analogously, if the double quote is
alpar@9: part of a string literal enclosed in double quotes, it must be coded
alpar@9: twice.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|'This is a string'|
alpar@9: 
alpar@9: \noindent\verb|"This is another string"|
alpar@9: 
alpar@9: \noindent\verb|'1 + 2 = 3'|
alpar@9: 
alpar@9: \noindent\verb|'That''s all'|
alpar@9: 
alpar@9: \noindent\verb|"She said: ""No"""|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: String literals are used to represent symbolic quantities.
alpar@9: 
alpar@9: \subsection{Keywords}
alpar@9: 
alpar@9: A {\it keyword} is a sequence of alphabetic characters and possibly
alpar@9: some special characters.
alpar@9: 
alpar@9: All keywords fall into two categories: {\it reserved keywords}, which
alpar@9: cannot be used as symbolic names, and {\it non-reserved keywords},
alpar@9: which being recognized by context can be used as symbolic names.
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: The reserved keywords are the following:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}p{.7in}p{.7in}p{.7in}p{.7in}@{}}
alpar@9: {\tt and}&{\tt else}&{\tt mod}&{\tt union}\\
alpar@9: {\tt by}&{\tt if}&{\tt not}&{\tt within}\\
alpar@9: {\tt cross}&{\tt in}&{\tt or}\\
alpar@9: {\tt diff}&{\tt inter}&{\tt symdiff}\\
alpar@9: {\tt div}&{\tt less}&{\tt then}\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Non-reserved keywords are described in following sections.
alpar@9: 
alpar@9: All the keywords have fixed meaning, which will be explained on
alpar@9: discussion of corresponding syntactic constructions, where the keywords
alpar@9: are used.
alpar@9: 
alpar@9: \subsection{Delimiters}
alpar@9: 
alpar@9: A {\it delimiter} is either a single special character or a sequence of
alpar@9: two special characters as follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}p{.3in}p{.3in}p{.3in}p{.3in}p{.3in}p{.3in}@{}}
alpar@9: {\tt+}&{\tt\textasciicircum}&{\tt==}&{\tt!}&{\tt:}&{\tt)}\\
alpar@9: {\tt-}&{\tt\&}&{\tt>=}&{\tt\&\&}&{\tt;}&{\tt[}\\
alpar@9: {\tt*}&{\tt<}&{\tt>}&{\tt||}&{\tt:=}&{\tt|}\\
alpar@9: {\tt/}&{\tt<=}&{\tt<>}&{\tt.}&{\tt..}&{\tt\{}\\
alpar@9: {\tt**}&{\tt=}&{\tt!=}&{\tt,}&{\tt(}&{\tt\}}\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: If the delimiter consists of two characters, there must be no spaces
alpar@9: between the characters.
alpar@9: 
alpar@9: All the delimiters have fixed meaning, which will be explained on
alpar@9: discussion corresponding syntactic constructions, where the delimiters
alpar@9: are used.
alpar@9: 
alpar@9: \subsection{Comments}
alpar@9: 
alpar@9: For documenting purposes the model description can be provided with
alpar@9: {\it comments}, which may have two different forms. The first form is
alpar@9: a {\it single-line comment}, which begins with the character {\tt\#}
alpar@9: and extends until end of line. The second form is a {\it comment
alpar@9: sequence}, which is a sequence of any characters enclosed within
alpar@9: {\tt/*} and {\tt*/}.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|param n := 10; # This is a comment|
alpar@9: 
alpar@9: \noindent\verb|/* This is another comment */|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Comments are ignored by the model translator and can appear anywhere in
alpar@9: the model description, where white-space characters are allowed.
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Expressions}
alpar@9: 
alpar@9: An {\it expression} is a rule for computing a value. In model
alpar@9: description expressions are used as constituents of certain statements.
alpar@9: 
alpar@9: In general case expressions consist of operands and operators.
alpar@9: 
alpar@9: Depending on the type of the resultant value all expressions fall into
alpar@9: the following categories:
alpar@9: 
alpar@9: \begin{itemize}
alpar@9: \item numeric expressions;
alpar@9: \item symbolic expressions;
alpar@9: \item indexing expressions;
alpar@9: \item set expressions;
alpar@9: \item logical expressions;
alpar@9: \item linear expressions.
alpar@9: \end{itemize}
alpar@9: 
alpar@9: \subsection{Numeric expressions}
alpar@9: 
alpar@9: A {\it numeric expression} is a rule for computing a single numeric
alpar@9: value represented as a floating-point number.
alpar@9: 
alpar@9: The primary numeric expression may be a numeric literal, dummy index,
alpar@9: unsubscripted parameter, subscripted parameter, built-in function
alpar@9: reference, iterated numeric expression, conditional numeric expression,
alpar@9: or another numeric expression enclosed in parentheses.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: \verb|1.23|&(numeric literal)\\
alpar@9: \verb|j|&(dummy index)\\
alpar@9: \verb|time|&(unsubscripted parameter)\\
alpar@9: \verb|a['May 2003',j+1]|&(subscripted parameter)\\
alpar@9: \verb|abs(b[i,j])|&(function reference)\\
alpar@9: \verb|sum{i in S diff T} alpha[i] * b[i,j]|&(iterated expression)\\
alpar@9: \verb|if i in I then 2 * p else q[i+1]|&(conditional expression)\\
alpar@9: \verb|(b[i,j] + .5 * c)|&(parenthesized expression)\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: More general numeric expressions containing two or more primary numeric
alpar@9: expressions may be constructed by using certain arithmetic operators.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|j+1|
alpar@9: 
alpar@9: \noindent\verb|2 * a[i-1,j+1] - b[i,j]|
alpar@9: 
alpar@9: \noindent\verb|sum{j in J} a[i,j] * x[j] + sum{k in K} b[i,k] * x[k]|
alpar@9: 
alpar@9: \noindent\verb|(if i in I then 2 * p else q[i+1]) / (a[i,j] + 1.5)|
alpar@9: 
alpar@9: \subsubsection{Numeric literals}
alpar@9: 
alpar@9: If the primary numeric expression is a numeric literal, the resultant
alpar@9: value is obvious.
alpar@9: 
alpar@9: \subsubsection{Dummy indices}
alpar@9: 
alpar@9: If the primary numeric expression is a dummy index, the resultant value
alpar@9: is current value assigned to that dummy index.
alpar@9: 
alpar@9: \subsubsection{Unsubscripted parameters}
alpar@9: 
alpar@9: If the primary numeric expression is an unsubscripted parameter (which
alpar@9: must be 0-dimensional), the resultant value is the value of that
alpar@9: parameter.
alpar@9: 
alpar@9: \subsubsection{Subscripted parameters}
alpar@9: 
alpar@9: The primary numeric expression, which refers to a subscripted parameter,
alpar@9: has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it name} is the symbolic name of the parameter,
alpar@9: $i_1$, $i_2$, \dots, $i_n$ are subscripts.
alpar@9: 
alpar@9: Each subscript must be a numeric or symbolic expression. The number of
alpar@9: subscripts in the subscript list must be the same as the dimension of
alpar@9: the parameter with which the subscript list is associated.
alpar@9: 
alpar@9: Actual values of subscript expressions are used to identify
alpar@9: a particular member of the parameter that determines the resultant
alpar@9: value of the primary expression.
alpar@9: 
alpar@9: \subsubsection{Function references}
alpar@9: 
alpar@9: In MathProg there exist the following built-in functions which may be
alpar@9: used in numeric expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt abs(}$x${\tt)}&$|x|$, absolute value of $x$\\
alpar@9: {\tt atan(}$x${\tt)}&$\arctan x$, principal value of the arc tangent of
alpar@9: $x$ (in radians)\\
alpar@9: {\tt atan(}$y${\tt,} $x${\tt)}&$\arctan y/x$, principal value of the
alpar@9: arc tangent of $y/x$ (in radians). In this case the signs of both
alpar@9: arguments $y$ and $x$ are used to determine the quadrant of the
alpar@9: resultant value\\
alpar@9: {\tt card(}$X${\tt)}&$|X|$, cardinality (the number of elements) of
alpar@9: set $X$\\
alpar@9: {\tt ceil(}$x${\tt)}&$\lceil x\rceil$, smallest integer not less than
alpar@9: $x$ (``ceiling of $x$'')\\
alpar@9: {\tt cos(}$x${\tt)}&$\cos x$, cosine of $x$ (in radians)\\
alpar@9: {\tt exp(}$x${\tt)}&$e^x$, base-$e$ exponential of $x$\\
alpar@9: {\tt floor(}$x${\tt)}&$\lfloor x\rfloor$, largest integer not greater
alpar@9: than $x$ (``floor of $x$'')\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt gmtime()}&the number of seconds elapsed since 00:00:00~Jan~1, 1970,
alpar@9: Coordinated Universal Time (for details see Subsection \ref{gmtime},
alpar@9: page \pageref{gmtime})\\
alpar@9: {\tt length(}$s${\tt)}&$|s|$, length of character string $s$\\
alpar@9: {\tt log(}$x${\tt)}&$\log x$, natural logarithm of $x$\\
alpar@9: {\tt log10(}$x${\tt)}&$\log_{10}x$, common (decimal) logarithm of $x$\\
alpar@9: {\tt max(}$x_1${\tt,} $x_2${\tt,} \dots{\tt,} $x_n${\tt)}&the largest
alpar@9: of values $x_1$, $x_2$, \dots, $x_n$\\
alpar@9: {\tt min(}$x_1${\tt,} $x_2${\tt,} \dots{\tt,} $x_n${\tt)}&the smallest
alpar@9: of values $x_1$, $x_2$, \dots, $x_n$\\
alpar@9: {\tt round(}$x${\tt)}&rounding $x$ to nearest integer\\
alpar@9: {\tt round(}$x${\tt,} $n${\tt)}&rounding $x$ to $n$ fractional decimal
alpar@9: digits\\
alpar@9: {\tt sin(}$x${\tt)}&$\sin x$, sine of $x$ (in radians)\\
alpar@9: {\tt sqrt(}$x${\tt)}&$\sqrt{x}$, non-negative square root of $x$\\
alpar@9: {\tt str2time(}$s${\tt,} $f${\tt)}&converting character string $s$ to
alpar@9: calendar time (for details see Subsection \ref{str2time}, page
alpar@9: \pageref{str2time})\\
alpar@9: {\tt trunc(}$x${\tt)}&truncating $x$ to nearest integer\\
alpar@9: {\tt trunc(}$x${\tt,} $n${\tt)}&truncating $x$ to $n$ fractional
alpar@9: decimal digits\\
alpar@9: {\tt Irand224()}&generating pseudo-random integer uniformly distributed
alpar@9: in $[0,2^{24})$\\
alpar@9: {\tt Uniform01()}&generating pseudo-random number uniformly distributed
alpar@9: in $[0,1)$\\
alpar@9: {\tt Uniform(}$a${\tt,} $b${\tt)}&generating pseudo-random number
alpar@9: uniformly distributed in $[a,b)$\\
alpar@9: {\tt Normal01()}&generating Gaussian pseudo-random variate with
alpar@9: $\mu=0$ and $\sigma=1$\\
alpar@9: {\tt Normal(}$\mu${\tt,} $\sigma${\tt)}&generating Gaussian
alpar@9: pseudo-random variate with given $\mu$ and $\sigma$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Arguments of all built-in functions, except {\tt card}, {\tt length},
alpar@9: and {\tt str2time}, must be numeric expressions. The argument of
alpar@9: {\tt card} must be a set expression. The argument of {\tt length} and
alpar@9: both arguments of {\tt str2time} must be symbolic expressions.
alpar@9: 
alpar@9: The resultant value of the numeric expression, which is a function
alpar@9: reference, is the result of applying the function to its argument(s).
alpar@9: 
alpar@9: Note that each pseudo-random generator function has a latent argument
alpar@9: (i.e. some internal state), which is changed whenever the function has
alpar@9: been applied. Thus, if the function is applied repeatedly even to
alpar@9: identical arguments, due to the side effect different resultant values
alpar@9: are always produced.
alpar@9: 
alpar@9: \subsubsection{Iterated expressions}
alpar@9: \label{itexpr}
alpar@9: 
alpar@9: An {\it iterated numeric expression} is a primary numeric expression,
alpar@9: which has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\it iterated-operator indexing-expression integrand}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it iterated-operator} is the symbolic name of the
alpar@9: iterated operator to be performed (see below), {\it indexing-expression}
alpar@9: is an indexing expression which introduces dummy indices and controls
alpar@9: iterating, {\it integrand} is a numeric expression that participates in
alpar@9: the operation.
alpar@9: 
alpar@9: In MathProg there exist four iterated operators, which may be used in
alpar@9: numeric expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}lll@{}}
alpar@9: {\tt sum}&summation&$\displaystyle\sum_{(i_1,\dots,i_n)\in\Delta}
alpar@9: f(i_1,\dots,i_n)$\\
alpar@9: {\tt prod}&production&$\displaystyle\prod_{(i_1,\dots,i_n)\in\Delta}
alpar@9: f(i_1,\dots,i_n)$\\
alpar@9: {\tt min}&minimum&$\displaystyle\min_{(i_1,\dots,i_n)\in\Delta}
alpar@9: f(i_1,\dots,i_n)$\\
alpar@9: {\tt max}&maximum&$\displaystyle\max_{(i_1,\dots,i_n)\in\Delta}
alpar@9: f(i_1,\dots,i_n)$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $i_1$, \dots, $i_n$ are dummy indices introduced in
alpar@9: the indexing expression, $\Delta$ is the domain, a set of $n$-tuples
alpar@9: specified by the indexing expression which defines particular values
alpar@9: assigned to the dummy indices on performing the iterated operation,
alpar@9: $f(i_1,\dots,i_n)$ is the integrand, a numeric expression whose
alpar@9: resultant value depends on the dummy indices.
alpar@9: 
alpar@9: The resultant value of an iterated numeric expression is the result of
alpar@9: applying of the iterated operator to its integrand over all $n$-tuples
alpar@9: contained in the domain.
alpar@9: 
alpar@9: \subsubsection{Conditional expressions}
alpar@9: \label{ifthen}
alpar@9: 
alpar@9: A {\it conditional numeric expression} is a primary numeric expression,
alpar@9: which has one of the following two syntactic forms:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt if} $b$ {\tt then} $x$ {\tt else} $y$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{126.5pt}
alpar@9: {\tt if} $b$ {\tt then} $x$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $b$ is an logical expression, $x$ and $y$ are numeric
alpar@9: expressions.
alpar@9: 
alpar@9: The resultant value of the conditional expression depends on the value
alpar@9: of the logical expression that follows the keyword {\tt if}. If it
alpar@9: takes on the value {\it true}, the value of the conditional expression
alpar@9: is the value of the expression that follows the keyword {\tt then}.
alpar@9: Otherwise, if the logical expression takes on the value {\it false},
alpar@9: the value of the conditional expression is the value of the expression
alpar@9: that follows the keyword {\it else}. If the second, reduced form of the
alpar@9: conditional expression is used and the logical expression takes on the
alpar@9: value {\it false}, the resultant value of the conditional expression is
alpar@9: zero.
alpar@9: 
alpar@9: \subsubsection{Parenthesized expressions}
alpar@9: 
alpar@9: Any numeric expression may be enclosed in parentheses that
alpar@9: syntactically makes it a primary numeric expression.
alpar@9: 
alpar@9: Parentheses may be used in numeric expressions, as in algebra, to
alpar@9: specify the desired order in which operations are to be performed.
alpar@9: Where parentheses are used, the expression within the parentheses is
alpar@9: evaluated before the resultant value is used.
alpar@9: 
alpar@9: The resultant value of the parenthesized expression is the same as the
alpar@9: value of the expression enclosed within parentheses.
alpar@9: 
alpar@9: \subsubsection{Arithmetic operators}
alpar@9: 
alpar@9: In MathProg there exist the following arithmetic operators, which may
alpar@9: be used in numeric expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt +} $x$&unary plus\\
alpar@9: {\tt -} $x$&unary minus\\
alpar@9: $x$ {\tt +} $y$&addition\\
alpar@9: $x$ {\tt -} $y$&subtraction\\
alpar@9: $x$ {\tt less} $y$&positive difference (if $x<y$ then 0 else $x-y$)\\
alpar@9: $x$ {\tt *} $y$&multiplication\\
alpar@9: $x$ {\tt /} $y$&division\\
alpar@9: $x$ {\tt div} $y$&quotient of exact division\\
alpar@9: $x$ {\tt mod} $y$&remainder of exact division\\
alpar@9: $x$ {\tt **} $y$, $x$ {\tt\textasciicircum} $y$&exponentiation (raising
alpar@9: to power)\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $x$ and $y$ are numeric expressions.
alpar@9: 
alpar@9: If the expression includes more than one arithmetic operator, all
alpar@9: operators are performed from left to right according to the hierarchy
alpar@9: of operations (see below) with the only exception that the
alpar@9: exponentiaion operators are performed from right to left.
alpar@9: 
alpar@9: The resultant value of the expression, which contains arithmetic
alpar@9: operators, is the result of applying the operators to their operands.
alpar@9: 
alpar@9: \subsubsection{Hierarchy of operations}
alpar@9: \label{hierarchy}
alpar@9: 
alpar@9: The following list shows the hierarchy of operations in numeric
alpar@9: expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: Operation&Hierarchy\\
alpar@9: \hline
alpar@9: Evaluation of functions ({\tt abs}, {\tt ceil}, etc.)&1st\\
alpar@9: Exponentiation ({\tt**}, {\tt\textasciicircum})&2nd\\
alpar@9: Unary plus and minus ({\tt+}, {\tt-})&3rd\\
alpar@9: Multiplication and division ({\tt*}, {\tt/}, {\tt div}, {\tt mod})&4th\\
alpar@9: Iterated operations ({\tt sum}, {\tt prod}, {\tt min}, {\tt max})&5th\\
alpar@9: Addition and subtraction ({\tt+}, {\tt-}, {\tt less})&6th\\
alpar@9: Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
alpar@9: 7th\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: This hierarchy is used to determine which of two consecutive operations
alpar@9: is performed first. If the first operator is higher than or equal to
alpar@9: the second, the first operation is performed. If it is not, the second
alpar@9: operator is compared to the third, etc. When the end of the expression
alpar@9: is reached, all of the remaining operations are performed in the
alpar@9: reverse order.
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \subsection{Symbolic expressions}
alpar@9: 
alpar@9: A {\it symbolic expression} is a rule for computing a single symbolic
alpar@9: value represented as a character string.
alpar@9: 
alpar@9: The primary symbolic expression may be a string literal, dummy index,
alpar@9: unsubscripted parameter, subscripted parameter, built-in function
alpar@9: reference, conditional symbolic expression, or another symbolic
alpar@9: expression enclosed in parentheses.
alpar@9: 
alpar@9: It is also allowed to use a numeric expression as the primary symbolic
alpar@9: expression, in which case the resultant value of the numeric expression
alpar@9: is automatically converted to the symbolic type.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: \verb|'May 2003'|&(string literal)\\
alpar@9: \verb|j|&(dummy index)\\
alpar@9: \verb|p|&(unsubscripted parameter)\\
alpar@9: \verb|s['abc',j+1]|&(subscripted parameter)\\
alpar@9: \verb|substr(name[i],k+1,3)|&(function reference)\\
alpar@9: \verb|if i in I then s[i,j] else t[i+1]|&(conditional expression)\\
alpar@9: \verb|((10 * b[i,j]) & '.bis')|&(parenthesized expression)\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: More general symbolic expressions containing two or more primary
alpar@9: symbolic expressions may be constructed by using the concatenation
alpar@9: operator.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|'abc[' & i & ',' & j & ']'|
alpar@9: 
alpar@9: \noindent\verb|"from " & city[i] & " to " & city[j]|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: The principles of evaluation of symbolic expressions are completely
alpar@9: analogous to the ones given for numeric expressions (see above).
alpar@9: 
alpar@9: \subsubsection{Function references}
alpar@9: 
alpar@9: In MathProg there exist the following built-in functions which may be
alpar@9: used in symbolic expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt substr(}$s${\tt,} $x${\tt)}&substring of $s$ starting from
alpar@9: position $x$\\
alpar@9: {\tt substr(}$s${\tt,} $x${\tt,} $y${\tt)}&substring of $s$ starting
alpar@9: from position $x$ and having length $y$\\
alpar@9: {\tt time2str(}$t${\tt,} $f${\tt)}&converting calendar time to
alpar@9: character string (for details see Subsection \ref{time2str}, page
alpar@9: \pageref{time2str})\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: The first argument of {\tt substr} must be a symbolic expression while
alpar@9: its second and optional third arguments must be numeric expressions.
alpar@9: 
alpar@9: The first argument of {\tt time2str} must be a numeric expression, and
alpar@9: its second argument must be a symbolic expression.
alpar@9: 
alpar@9: The resultant value of the symbolic expression, which is a function
alpar@9: reference, is the result of applying the function to its arguments.
alpar@9: 
alpar@9: \subsubsection{Symbolic operators}
alpar@9: 
alpar@9: Currently in MathProg there exists the only symbolic operator:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt s \& t}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $s$ and $t$ are symbolic expressions. This operator
alpar@9: means concatenation of its two symbolic operands, which are character
alpar@9: strings.
alpar@9: 
alpar@9: \subsubsection{Hierarchy of operations}
alpar@9: 
alpar@9: The following list shows the hierarchy of operations in symbolic
alpar@9: expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: Operation&Hierarchy\\
alpar@9: \hline
alpar@9: Evaluation of numeric operations&1st-7th\\
alpar@9: Concatenation ({\tt\&})&8th\\
alpar@9: Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
alpar@9: 7th\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: This hierarchy has the same meaning as was explained above for numeric
alpar@9: expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
alpar@9: 
alpar@9: \subsection{Indexing expressions and dummy indices}
alpar@9: \label{indexing}
alpar@9: 
alpar@9: An {\it indexing expression} is an auxiliary construction, which
alpar@9: specifies a plain set of $n$-tuples and introduces dummy indices. It
alpar@9: has two syntactic forms:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{73.5pt}
alpar@9: {\tt\{} {\it entry}$_1${\tt,} {\it entry}$_2${\tt,} \dots{\tt,}
alpar@9: {\it entry}$_m$ {\tt\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt\{} {\it entry}$_1${\tt,} {\it entry}$_2${\tt,} \dots{\tt,}
alpar@9: {\it entry}$_m$ {\tt:} {\it predicate} {\tt\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it entry}{$_1$}, {\it entry}{$_2$}, \dots,
alpar@9: {\it entry}{$_m$} are indexing entries, {\it predicate} is a logical
alpar@9: expression that specifies an optional predicate (logical condition).
alpar@9: 
alpar@9: Each {\it indexing entry} in the indexing expression has one of the
alpar@9: following three forms:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{123pt}
alpar@9: $i$ {\tt in} $S$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt(}$i_1${\tt,} $i_2${\tt,} \dots{\tt,}$i_n${\tt)} {\tt in} $S$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{123pt}
alpar@9: $S$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $i_1$, $i_2$, \dots, $i_n$ are indices, $S$ is a set
alpar@9: expression (discussed in the next section) that specifies the basic set.
alpar@9: 
alpar@9: The number of indices in the indexing entry must be the same as the
alpar@9: dimension of the basic set $S$, i.e. if $S$ consists of 1-tuples, the
alpar@9: first form must be used, and if $S$ consists of $n$-tuples, where
alpar@9: $n>1$, the second form must be used.
alpar@9: 
alpar@9: If the first form of the indexing entry is used, the index $i$ can be
alpar@9: a dummy index only (see below). If the second form is used, the indices
alpar@9: $i_1$, $i_2$, \dots, $i_n$ can be either dummy indices or some numeric
alpar@9: or symbolic expressions, where at least one index must be a dummy index.
alpar@9: The third, reduced form of the indexing entry has the same effect as if
alpar@9: there were $i$ (if $S$ is 1-dimensional) or $i_1$, $i_2$, \dots, $i_n$
alpar@9: (if $S$ is $n$-dimensional) all specified as dummy indices.
alpar@9: 
alpar@9: A {\it dummy index} is an auxiliary model object, which acts like an
alpar@9: individual variable. Values assigned to dummy indices are components of
alpar@9: $n$-tuples from basic sets, i.e. some numeric and symbolic quantities.
alpar@9: 
alpar@9: For referencing purposes dummy indices can be provided with symbolic
alpar@9: names. However, unlike other model objects (sets, parameters, etc.)
alpar@9: dummy indices need not be explicitly declared. Each {\it undeclared}
alpar@9: symbolic name being used in the indexing position of an indexing entry
alpar@9: is recognized as the symbolic name of corresponding dummy index.
alpar@9: 
alpar@9: Symbolic names of dummy indices are valid only within the scope of the
alpar@9: indexing expression, where the dummy indices were introduced. Beyond
alpar@9: the scope the dummy indices are completely inaccessible, so the same
alpar@9: symbolic names may be used for other purposes, in particular, to
alpar@9: represent dummy indices in other indexing expressions.
alpar@9: 
alpar@9: The scope of indexing expression, where implicit declarations of dummy
alpar@9: indices are valid, depends on the context, in which the indexing
alpar@9: expression is used:
alpar@9: 
alpar@9: \begin{enumerate}
alpar@9: \item If the indexing expression is used in iterated operator, its
alpar@9: scope extends until the end of the integrand.
alpar@9: \item If the indexing expression is used as a primary set expression,
alpar@9: its scope extends until the end of that indexing expression.
alpar@9: \item If the indexing expression is used to define the subscript domain
alpar@9: in declarations of some model objects, its scope extends until the end
alpar@9: of the corresponding statement.
alpar@9: \end{enumerate}
alpar@9: 
alpar@9: The indexing mechanism implemented by means of indexing expressions is
alpar@9: best explained by some examples discussed below.
alpar@9: 
alpar@9: Let there be given three sets:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{33.5pt}
alpar@9: $A=\{4,7,9\}$,
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: $B=\{(1,Jan),(1,Feb),(2,Mar),(2,Apr),(3,May),(3,Jun)\}$,
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{33.5pt}
alpar@9: $C=\{a,b,c\}$,
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $A$ and $C$ consist of 1-tuples (singlets), $B$
alpar@9: consists of 2-tuples (doublets). Consider the following indexing
alpar@9: expression:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt\{i in A, (j,k) in B, l in C\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\tt i}, {\tt j}, {\tt k}, and {\tt l} are dummy
alpar@9: indices.
alpar@9: 
alpar@9: Although MathProg is not a procedural language, for any indexing
alpar@9: expression an equivalent algorithmic description can be given. In
alpar@9: particular, the algorithmic description of the indexing expression
alpar@9: above could look like follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}l@{}}
alpar@9: {\bf for all} $i\in A$ {\bf do}\\
alpar@9: \hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf do}\\
alpar@9: \hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
alpar@9: \hspace{36pt}{\it action};\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \noindent where the dummy indices $i$, $j$, $k$, $l$ are consecutively
alpar@9: assigned corresponding components of $n$-tuples from the basic sets $A$,
alpar@9: $B$, $C$, and {\it action} is some action that depends on the context,
alpar@9: where the indexing expression is used. For example, if the action were
alpar@9: printing current values of dummy indices, the printout would look like
alpar@9: follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}llll@{}}
alpar@9: $i=4$&$j=1$&$k=Jan$&$l=a$\\
alpar@9: $i=4$&$j=1$&$k=Jan$&$l=b$\\
alpar@9: $i=4$&$j=1$&$k=Jan$&$l=c$\\
alpar@9: $i=4$&$j=1$&$k=Feb$&$l=a$\\
alpar@9: $i=4$&$j=1$&$k=Feb$&$l=b$\\
alpar@9: \multicolumn{4}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
alpar@9: $i=9$&$j=3$&$k=Jun$&$l=b$\\
alpar@9: $i=9$&$j=3$&$k=Jun$&$l=c$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Let the example indexing expression be used in the following iterated
alpar@9: operation:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt sum\{i in A, (j,k) in B, l in C\} p[i,j,k,l]}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\tt p} is a 4-dimensional numeric parameter or some
alpar@9: numeric expression whose resultant value depends on {\tt i}, {\tt j},
alpar@9: {\tt k}, and {\tt l}. In this case the action is summation, so the
alpar@9: resultant value of the primary numeric expression is:
alpar@9: $$\sum_{i\in A,(j,k)\in B,l\in C}(p_{ijkl}).$$
alpar@9: 
alpar@9: Now let the example indexing expression be used as a primary set
alpar@9: expression. In this case the action is gathering all 4-tuples
alpar@9: (quadruplets) of the form $(i,j,k,l)$ in one set, so the resultant
alpar@9: value of such operation is simply the Cartesian product of the basic
alpar@9: sets:
alpar@9: $$A\times B\times C=\{(i,j,k,l):i\in A,(j,k)\in B,l\in C\}.$$
alpar@9: Note that in this case the same indexing expression might be written in
alpar@9: the reduced form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt\{A, B, C\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent because the dummy indices $i$, $j$, $k$, and $l$ are not
alpar@9: referenced and therefore their symbolic names need not be specified.
alpar@9: 
alpar@9: Finally, let the example indexing expression be used as the subscript
alpar@9: domain in the declaration of a 4-dimensional model object, say,
alpar@9: a numeric parameter:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt param p\{i in A, (j,k) in B, l in C\}} \dots {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent In this case the action is generating the parameter members,
alpar@9: where each member has the form $p[i,j,k,l]$.
alpar@9: 
alpar@9: As was said above, some indices in the second form of indexing entries
alpar@9: may be numeric or symbolic expressions, not only dummy indices. In this
alpar@9: case resultant values of such expressions play role of some logical
alpar@9: conditions to select only that $n$-tuples from the Cartesian product of
alpar@9: basic sets that satisfy these conditions.
alpar@9: 
alpar@9: Consider, for example, the following indexing expression:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt\{i in A, (i-1,k) in B, l in C\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\tt i}, {\tt k}, {\tt l} are dummy indices, and
alpar@9: {\tt i-1} is a numeric expression. The algorithmic decsription of this
alpar@9: indexing expression is the following:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}l@{}}
alpar@9: {\bf for all} $i\in A$ {\bf do}\\
alpar@9: \hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf and} $j=i-1$ {\bf do}\\
alpar@9: \hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
alpar@9: \hspace{36pt}{\it action};\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent Thus, if this indexing expression were used as a primary set
alpar@9: expression, the resultant set would be the following:
alpar@9: $$\{(4,May,a),(4,May,b),(4,May,c),(4,Jun,a),(4,Jun,b),(4,Jun,c)\}.$$
alpar@9: Should note that in this case the resultant set consists of 3-tuples,
alpar@9: not of 4-tuples, because in the indexing expression there is no dummy
alpar@9: index that corresponds to the first component of 2-tuples from the set
alpar@9: $B$.
alpar@9: 
alpar@9: The general rule is: the number of components of $n$-tuples defined by
alpar@9: an indexing expression is the same as the number of dummy indices in
alpar@9: that expression, where the correspondence between dummy indices and
alpar@9: components on $n$-tuples in the resultant set is positional, i.e. the
alpar@9: first dummy index corresponds to the first component, the second dummy
alpar@9: index corresponds to the second component, etc.
alpar@9: 
alpar@9: In some cases it is needed to select a subset from the Cartesian
alpar@9: product of some sets. This may be attained by using an optional logical
alpar@9: predicate, which is specified in the indexing expression.
alpar@9: 
alpar@9: Consider, for example, the following indexing expression:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt\{i in A, (j,k) in B, l in C: i <= 5 and k <> 'Mar'\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where the logical expression following the colon is a
alpar@9: predicate. The algorithmic description of this indexing expression is
alpar@9: the following:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}l@{}}
alpar@9: {\bf for all} $i\in A$ {\bf do}\\
alpar@9: \hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf do}\\
alpar@9: \hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
alpar@9: \hspace{36pt}{\bf if} $i\leq 5$ {\bf and} $l\neq`Mar'$ {\bf then}\\
alpar@9: \hspace{48pt}{\it action};\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent Thus, if this indexing expression were used as a primary set
alpar@9: expression, the resultant set would be the following:
alpar@9: $$\{(4,1,Jan,a),(4,1,Feb,a),(4,2,Apr,a),\dots,(4,3,Jun,c)\}.$$
alpar@9: 
alpar@9: If no predicate is specified in the indexing expression, one, which
alpar@9: takes on the value {\it true}, is assumed.
alpar@9: 
alpar@9: \subsection{Set expressions}
alpar@9: 
alpar@9: A {\it set expression} is a rule for computing an elemental set, i.e.
alpar@9: a collection of $n$-tuples, where components of $n$-tuples are numeric
alpar@9: and symbolic quantities.
alpar@9: 
alpar@9: The primary set expression may be a literal set, unsubscripted set,
alpar@9: subscripted set, ``arithmetic'' set, indexing expression, iterated set
alpar@9: expression, conditional set expression, or another set expression
alpar@9: enclosed in parentheses.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: \verb|{(123,'aa'), (i,'bb'), (j-1,'cc')}|&(literal set)\\
alpar@9: \verb|I|&(unsubscripted set)\\
alpar@9: \verb|S[i-1,j+1]|&(subscripted set)\\
alpar@9: \verb|1..t-1 by 2|&(``arithmetic'' set)\\
alpar@9: \verb|{t in 1..T, (t+1,j) in S: (t,j) in F}|&(indexing expression)\\
alpar@9: \verb|setof{i in I, j in J}(i+1,j-1)|&(iterated expression)\\
alpar@9: \verb|if i < j then S[i] else F diff S[j]|&(conditional expression)\\
alpar@9: \verb|(1..10 union 21..30)|&(parenthesized expression)\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: More general set expressions containing two or more primary set
alpar@9: expressions may be constructed by using certain set operators.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|(A union B) inter (I cross J)|
alpar@9: 
alpar@9: \noindent
alpar@9: \verb|1..10 cross (if i < j then {'a', 'b', 'c'} else {'d', 'e', 'f'})|
alpar@9: 
alpar@9: \subsubsection{Literal sets}
alpar@9: 
alpar@9: A {\it literal set} is a primary set expression, which has the
alpar@9: following two syntactic forms:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{39pt}
alpar@9: {\tt\{}$e_1${\tt,} $e_2${\tt,} \dots{\tt,} $e_m${\tt\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt\{(}$e_{11}${\tt,} \dots{\tt,} $e_{1n}${\tt),}
alpar@9: {\tt(}$e_{21}${\tt,} \dots{\tt,} $e_{2n}${\tt),} \dots{\tt,}
alpar@9: {\tt(}$e_{m1}${\tt,} \dots{\tt,} $e_{mn}${\tt)\}}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $e_1$, \dots, $e_m$, $e_{11}$, \dots, $e_{mn}$ are
alpar@9: numeric or symbolic expressions.
alpar@9: 
alpar@9: If the first form is used, the resultant set consists of 1-tuples
alpar@9: (singlets) enumerated within the curly braces. It is allowed to specify
alpar@9: an empty set as {\tt\{\ \}}, which has no 1-tuples. If the second form
alpar@9: is used, the resultant set consists of $n$-tuples enumerated within the
alpar@9: curly braces, where a particular $n$-tuple consists of corresponding
alpar@9: components enumerated within the parentheses. All $n$-tuples must have
alpar@9: the same number of components.
alpar@9: 
alpar@9: \subsubsection{Unsubscripted sets}
alpar@9: 
alpar@9: If the primary set expression is an unsubscripted set (which must be
alpar@9: 0-dimen\-sional), the resultant set is an elemental set associated with
alpar@9: the corresponding set object.
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \subsubsection{Subscripted sets}
alpar@9: 
alpar@9: The primary set expression, which refers to a subscripted set, has the
alpar@9: following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it name} is the symbolic name of the set object,
alpar@9: $i_1$, $i_2$, \dots, $i_n$ are subscripts.
alpar@9: 
alpar@9: Each subscript must be a numeric or symbolic expression. The number of
alpar@9: subscripts in the subscript list must be the same as the dimension of
alpar@9: the set object with which the subscript list is associated.
alpar@9: 
alpar@9: Actual values of subscript expressions are used to identify a
alpar@9: particular member of the set object that determines the resultant set.
alpar@9: 
alpar@9: \subsubsection{``Arithmetic'' sets}
alpar@9: 
alpar@9: The primary set expression, which is an ``arithmetic'' set, has the
alpar@9: following two syntactic forms:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: $t_0$ {\tt..} $t_1$ {\tt by} $\delta t$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{138.5pt}
alpar@9: $t_0$ {\tt..} $t_1$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $t_0$, $t_1$, and $\delta t$ are numeric expressions
alpar@9: (the value of $\delta t$ must not be zero). The second form is
alpar@9: equivalent to the first form, where $\delta t=1$.
alpar@9: 
alpar@9: If $\delta t>0$, the resultant set is determined as follows:
alpar@9: $$\{t:\exists k\in{\cal Z}(t=t_0+k\delta t,\ t_0\leq t\leq t_1)\}.$$
alpar@9: Otherwise, if $\delta t<0$, the resultant set is determined as follows:
alpar@9: $$\{t:\exists k\in{\cal Z}(t=t_0+k\delta t,\ t_1\leq t\leq t_0)\}.$$
alpar@9: 
alpar@9: \subsubsection{Indexing expressions}
alpar@9: 
alpar@9: If the primary set expression is an indexing expression, the resultant
alpar@9: set is determined as described above in Subsection \ref{indexing}, page
alpar@9: \pageref{indexing}.
alpar@9: 
alpar@9: \subsubsection{Iterated expressions}
alpar@9: 
alpar@9: An {\it iterated set expression} is a primary set expression, which has
alpar@9: the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt setof} {\it indexing-expression} {\it integrand}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it indexing-expression} is an indexing expression,
alpar@9: which introduces dummy indices and controls iterating, {\it integrand}
alpar@9: is either a single numeric or symbolic expression or a list of numeric
alpar@9: and symbolic expressions separated by commae and enclosed in
alpar@9: parentheses.
alpar@9: 
alpar@9: If the integrand is a single numeric or symbolic expression, the
alpar@9: resultant set consists of 1-tuples and is determined as follows:
alpar@9: $$\{x:(i_1,\dots,i_n)\in\Delta\},$$
alpar@9: \noindent where $x$ is a value of the integrand, $i_1$, \dots, $i_n$
alpar@9: are dummy indices introduced in the indexing expression, $\Delta$ is
alpar@9: the domain, a set of $n$-tuples specified by the indexing expression,
alpar@9: which defines particular values assigned to the dummy indices on
alpar@9: performing the iterated operation.
alpar@9: 
alpar@9: If the integrand is a list containing $m$ numeric and symbolic
alpar@9: expressions, the resultant set consists of $m$-tuples and is determined
alpar@9: as follows:
alpar@9: $$\{(x_1,\dots,x_m):(i_1,\dots,i_n)\in\Delta\},$$
alpar@9: where $x_1$, \dots, $x_m$ are values of the expressions in the
alpar@9: integrand list, $i_1$, \dots, $i_n$ and $\Delta$ have the same meaning
alpar@9: as above.
alpar@9: 
alpar@9: \subsubsection{Conditional expressions}
alpar@9: 
alpar@9: A {\it conditional set expression} is a primary set expression that has
alpar@9: the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt if} $b$ {\tt then} $X$ {\tt else} $Y$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $b$ is an logical expression, $X$ and $Y$ are set
alpar@9: expressions, which must define sets of the same dimension.
alpar@9: 
alpar@9: The resultant value of the conditional expression depends on the value
alpar@9: of the logical expression that follows the keyword {\tt if}. If it
alpar@9: takes on the value {\it true}, the resultant set is the value of the
alpar@9: expression that follows the keyword {\tt then}. Otherwise, if the
alpar@9: logical expression takes on the value {\it false}, the resultant set is
alpar@9: the value of the expression that follows the keyword {\tt else}.
alpar@9: 
alpar@9: \subsubsection{Parenthesized expressions}
alpar@9: 
alpar@9: Any set expression may be enclosed in parentheses that syntactically
alpar@9: makes it a primary set expression.
alpar@9: 
alpar@9: Parentheses may be used in set expressions, as in algebra, to specify
alpar@9: the desired order in which operations are to be performed. Where
alpar@9: parentheses are used, the expression within the parentheses is
alpar@9: evaluated before the resultant value is used.
alpar@9: 
alpar@9: The resultant value of the parenthesized expression is the same as the
alpar@9: value of the expression enclosed within parentheses.
alpar@9: 
alpar@9: \subsubsection{Set operators}
alpar@9: 
alpar@9: In MathProg there exist the following set operators, which may be used
alpar@9: in set expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: $X$ {\tt union} $Y$&union $X\cup Y$\\
alpar@9: $X$ {\tt diff} $Y$&difference $X\backslash Y$\\
alpar@9: $X$ {\tt symdiff} $Y$&symmetric difference $X\oplus Y$\\
alpar@9: $X$ {\tt inter} $Y$&intersection $X\cap Y$\\
alpar@9: $X$ {\tt cross} $Y$&cross (Cartesian) product $X\times Y$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $X$ and Y are set expressions, which must define sets
alpar@9: of the identical dimension (except the Cartesian product).
alpar@9: 
alpar@9: If the expression includes more than one set operator, all operators
alpar@9: are performed from left to right according to the hierarchy of
alpar@9: operations (see below).
alpar@9: 
alpar@9: The resultant value of the expression, which contains set operators, is
alpar@9: the result of applying the operators to their operands.
alpar@9: 
alpar@9: The dimension of the resultant set, i.e. the dimension of $n$-tuples,
alpar@9: of which the resultant set consists of, is the same as the dimension of
alpar@9: the operands, except the Cartesian product, where the dimension of the
alpar@9: resultant set is the sum of the dimensions of its operands.
alpar@9: 
alpar@9: \subsubsection{Hierarchy of operations}
alpar@9: 
alpar@9: The following list shows the hierarchy of operations in set
alpar@9: expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: Operation&Hierarchy\\
alpar@9: \hline
alpar@9: Evaluation of numeric operations&1st-7th\\
alpar@9: Evaluation of symbolic operations&8th-9th\\
alpar@9: Evaluation of iterated or ``arithmetic'' set ({\tt setof}, {\tt..})&
alpar@9: 10th\\
alpar@9: Cartesian product ({\tt cross})&11th\\
alpar@9: Intersection ({\tt inter})&12th\\
alpar@9: Union and difference ({\tt union}, {\tt diff}, {\tt symdiff})&13th\\
alpar@9: Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
alpar@9: 14th\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: This hierarchy has the same meaning as was explained above for numeric
alpar@9: expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
alpar@9: 
alpar@9: \subsection{Logical expressions}
alpar@9: 
alpar@9: A {\it logical expression} is a rule for computing a single logical
alpar@9: value, which can be either {\it true} or {\it false}.
alpar@9: 
alpar@9: The primary logical expression may be a numeric expression, relational
alpar@9: expression, iterated logical expression, or another logical expression
alpar@9: enclosed in parentheses.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: \verb|i+1|&(numeric expression)\\
alpar@9: \verb|a[i,j] < 1.5|&(relational expression)\\
alpar@9: \verb|s[i+1,j-1] <> 'Mar'|&(relational expression)\\
alpar@9: \verb|(i+1,'Jan') not in I cross J|&(relational expression)\\
alpar@9: \verb|S union T within A[i] inter B[j]|&(relational expression)\\
alpar@9: \verb|forall{i in I, j in J} a[i,j] < .5 * b|&(iterated expression)\\
alpar@9: \verb|(a[i,j] < 1.5 or b[i] >= a[i,j])|&(parenthesized expression)\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: More general logical expressions containing two or more primary logical
alpar@9: expressions may be constructed by using certain logical operators.
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|not (a[i,j] < 1.5 or b[i] >= a[i,j]) and (i,j) in S|
alpar@9: 
alpar@9: \noindent\verb|(i,j) in S or (i,j) not in T diff U|
alpar@9: 
alpar@9: \subsubsection{Numeric expressions}
alpar@9: 
alpar@9: The resultant value of the primary logical expression, which is a
alpar@9: numeric expression, is {\it true}, if the resultant value of the
alpar@9: numeric expression is non-zero. Otherwise the resultant value of the
alpar@9: logical expression is {\it false}.
alpar@9: 
alpar@9: \subsubsection{Relational operators}
alpar@9: 
alpar@9: In MathProg there exist the following relational operators, which may
alpar@9: be used in logical expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: $x$ {\tt<} $y$&test on $x<y$\\
alpar@9: $x$ {\tt<=} $y$&test on $x\leq y$\\
alpar@9: $x$ {\tt=} $y$, $x$ {\tt==} $y$&test on $x=y$\\
alpar@9: $x$ {\tt>=} $y$&test on $x\geq y$\\
alpar@9: $x$ {\tt>} $y$&test on $x>y$\\
alpar@9: $x$ {\tt<>} $y$, $x$ {\tt!=} $y$&test on $x\neq y$\\
alpar@9: $x$ {\tt in} $Y$&test on $x\in Y$\\
alpar@9: {\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt in} $Y$&test on
alpar@9: $(x_1,\dots,x_n)\in Y$\\
alpar@9: $x$ {\tt not} {\tt in} $Y$, $x$ {\tt!in} $Y$&test on $x\not\in Y$\\
alpar@9: {\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt not} {\tt in} $Y$,
alpar@9: {\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt !in} $Y$&test on
alpar@9: $(x_1,\dots,x_n)\not\in Y$\\
alpar@9: $X$ {\tt within} $Y$&test on $X\subseteq Y$\\
alpar@9: $X$ {\tt not} {\tt within} $Y$, $X$ {\tt !within} $Y$&test on
alpar@9: $X\not\subseteq Y$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $x$, $x_1$, \dots, $x_n$, $y$ are numeric or symbolic
alpar@9: expressions, $X$ and $Y$ are set expression.
alpar@9: 
alpar@9: {\it Notes:}
alpar@9: 
alpar@9: 1. In the operations {\tt in}, {\tt not in}, and {\tt !in} the
alpar@9: number of components in the first operands must be the same as the
alpar@9: dimension of the second operand.
alpar@9: 
alpar@9: 2. In the operations {\tt within}, {\tt not within}, and {\tt !within}
alpar@9: both operands must have identical dimension.
alpar@9: 
alpar@9: All the relational operators listed above have their conventional
alpar@9: mathematical meaning. The resultant value is {\it true}, if
alpar@9: corresponding relation is satisfied for its operands, otherwise
alpar@9: {\it false}. (Note that symbolic values are ordered lexicographically,
alpar@9: and any numeric value precedes any symbolic value.)
alpar@9: 
alpar@9: \subsubsection{Iterated expressions}
alpar@9: 
alpar@9: An {\it iterated logical expression} is a primary logical expression,
alpar@9: which has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\it iterated-operator} {\it indexing-expression} {\it integrand}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it iterated-operator} is the symbolic name of the
alpar@9: iterated operator to be performed (see below), {\it indexing-expression}
alpar@9: is an indexing expression which introduces dummy indices and controls
alpar@9: iterating, {\it integrand} is a numeric expression that participates in
alpar@9: the operation.
alpar@9: 
alpar@9: In MathProg there exist two iterated operators, which may be used in
alpar@9: logical expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}lll@{}}
alpar@9: {\tt forall}&$\forall$-quantification&$\displaystyle
alpar@9: \forall(i_1,\dots,i_n)\in\Delta[f(i_1,\dots,i_n)],$\\
alpar@9: {\tt exists}&$\exists$-quantification&$\displaystyle
alpar@9: \exists(i_1,\dots,i_n)\in\Delta[f(i_1,\dots,i_n)],$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $i_1$, \dots, $i_n$ are dummy indices introduced in
alpar@9: the indexing expression, $\Delta$ is the domain, a set of $n$-tuples
alpar@9: specified by the indexing expression which defines particular values
alpar@9: assigned to the dummy indices on performing the iterated operation,
alpar@9: $f(i_1,\dots,i_n)$ is the integrand, a logical expression whose
alpar@9: resultant value depends on the dummy indices.
alpar@9: 
alpar@9: For $\forall$-quantification the resultant value of the iterated
alpar@9: logical expression is {\it true}, if the value of the integrand is
alpar@9: {\it true} for all $n$-tuples contained in the domain, otherwise
alpar@9: {\it false}.
alpar@9: 
alpar@9: For $\exists$-quantification the resultant value of the iterated
alpar@9: logical expression is {\it false}, if the value of the integrand is
alpar@9: {\it false} for all $n$-tuples contained in the domain, otherwise
alpar@9: {\it true}.
alpar@9: 
alpar@9: \subsubsection{Parenthesized expressions}
alpar@9: 
alpar@9: Any logical expression may be enclosed in parentheses that
alpar@9: syntactically makes it a primary logical expression.
alpar@9: 
alpar@9: Parentheses may be used in logical expressions, as in algebra, to
alpar@9: specify the desired order in which operations are to be performed.
alpar@9: Where parentheses are used, the expression within the parentheses is
alpar@9: evaluated before the resultant value is used.
alpar@9: 
alpar@9: The resultant value of the parenthesized expression is the same as the
alpar@9: value of the expression enclosed within parentheses.
alpar@9: 
alpar@9: \subsubsection{Logical operators}
alpar@9: 
alpar@9: In MathProg there exist the following logical operators, which may be
alpar@9: used in logical expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt not} $x$, {\tt!}$x$&negation $\neg\ x$\\
alpar@9: $x$ {\tt and} $y$, $x$ {\tt\&\&} $y$&conjunction (logical ``and'')
alpar@9: $x\;\&\;y$\\
alpar@9: $x$ {\tt or} $y$, $x$ {\tt||} $y$&disjunction (logical ``or'')
alpar@9: $x\vee y$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $x$ and $y$ are logical expressions.
alpar@9: 
alpar@9: If the expression includes more than one logical operator, all
alpar@9: operators are performed from left to right according to the hierarchy
alpar@9: of the operations (see below). The resultant value of the expression,
alpar@9: which contains logical operators, is the result of applying the
alpar@9: operators to their operands.
alpar@9: 
alpar@9: \subsubsection{Hierarchy of operations}
alpar@9: 
alpar@9: The following list shows the hierarchy of operations in logical
alpar@9: expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: Operation&Hierarchy\\
alpar@9: \hline
alpar@9: Evaluation of numeric operations&1st-7th\\
alpar@9: Evaluation of symbolic operations&8th-9th\\
alpar@9: Evaluation of set operations&10th-14th\\
alpar@9: Relational operations ({\tt<}, {\tt<=}, etc.)&15th\\
alpar@9: Negation ({\tt not}, {\tt!})&16th\\
alpar@9: Conjunction ({\tt and}, {\tt\&\&})&17th\\
alpar@9: $\forall$- and $\exists$-quantification ({\tt forall}, {\tt exists})&
alpar@9: 18th\\
alpar@9: Disjunction ({\tt or}, {\tt||})&19th\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: This hierarchy has the same meaning as was explained above for numeric
alpar@9: expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
alpar@9: 
alpar@9: \subsection{Linear expressions}
alpar@9: 
alpar@9: An {\it linear expression} is a rule for computing so called
alpar@9: a {\it linear form} or simply a {\it formula}, which is a linear (or
alpar@9: affine) function of elemental variables.
alpar@9: 
alpar@9: The primary linear expression may be an unsubscripted variable,
alpar@9: subscripted variable, iterated linear expression, conditional linear
alpar@9: expression, or another linear expression enclosed in parentheses.
alpar@9: 
alpar@9: It is also allowed to use a numeric expression as the primary linear
alpar@9: expression, in which case the resultant value of the numeric expression
alpar@9: is automatically converted to a formula that includes the constant term
alpar@9: only.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: \verb|z|&(unsubscripted variable)\\
alpar@9: \verb|x[i,j]|&(subscripted variable)\\
alpar@9: \verb|sum{j in J} (a[i] * x[i,j] + 3 * y)|&(iterated expression)\\
alpar@9: \verb|if i in I then x[i,j] else 1.5 * z + 3|&(conditional expression)\\
alpar@9: \verb|(a[i,j] * x[i,j] + y[i-1] + .1)|&(parenthesized expression)\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: More general linear expressions containing two or more primary linear
alpar@9: expressions may be constructed by using certain arithmetic operators.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\verb|2 * x[i-1,j+1] + 3.5 * y[k] + .5 * z|
alpar@9: 
alpar@9: \noindent\verb|(- x[i,j] + 3.5 * y[k]) / sum{t in T} abs(d[i,j,t])|
alpar@9: 
alpar@9: \subsubsection{Unsubscripted variables}
alpar@9: 
alpar@9: If the primary linear expression is an unsubscripted variable (which
alpar@9: must be 0-dimensional), the resultant formula is that unsubscripted
alpar@9: variable.
alpar@9: 
alpar@9: \subsubsection{Subscripted variables}
alpar@9: 
alpar@9: The primary linear expression, which refers to a subscripted variable,
alpar@9: has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it name} is the symbolic name of the model variable,
alpar@9: $i_1$, $i_2$, \dots, $i_n$ are subscripts.
alpar@9: 
alpar@9: Each subscript must be a numeric or symbolic expression. The number of
alpar@9: subscripts in the subscript list must be the same as the dimension of
alpar@9: the model variable with which the subscript list is associated.
alpar@9: 
alpar@9: Actual values of the subscript expressions are used to identify a
alpar@9: particular member of the model variable that determines the resultant
alpar@9: formula, which is an elemental variable associated with corresponding
alpar@9: member.
alpar@9: 
alpar@9: \subsubsection{Iterated expressions}
alpar@9: 
alpar@9: An {\it iterated linear expression} is a primary linear expression,
alpar@9: which has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt sum} {\it indexing-expression} {\it integrand}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where {\it indexing-expression} is an indexing expression,
alpar@9: which introduces dummy indices and controls iterating, {\it integrand}
alpar@9: is a linear expression that participates in the operation.
alpar@9: 
alpar@9: The iterated linear expression is evaluated exactly in the same way as
alpar@9: the iterated numeric expression (see Subection \ref{itexpr}, page
alpar@9: \pageref{itexpr}) with exception that the integrand participated in the
alpar@9: summation is a formula, not a numeric value.
alpar@9: 
alpar@9: \subsubsection{Conditional expressions}
alpar@9: 
alpar@9: A {\it conditional linear expression} is a primary linear expression,
alpar@9: which has one of the following two syntactic forms:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt if} $b$ {\tt then} $f$ {\tt else} $g$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hspace{127pt}
alpar@9: {\tt if} $b$ {\tt then} $f$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $b$ is an logical expression, $f$ and $g$ are linear
alpar@9: expressions.
alpar@9: 
alpar@9: The conditional linear expression is evaluated exactly in the same way
alpar@9: as the conditional numeric expression (see Subsection \ref{ifthen},
alpar@9: page \pageref{ifthen}) with exception that operands participated in the
alpar@9: operation are formulae, not numeric values.
alpar@9: 
alpar@9: \subsubsection{Parenthesized expressions}
alpar@9: 
alpar@9: Any linear expression may be enclosed in parentheses that syntactically
alpar@9: makes it a primary linear expression.
alpar@9: 
alpar@9: Parentheses may be used in linear expressions, as in algebra, to
alpar@9: specify the desired order in which operations are to be performed.
alpar@9: Where parentheses are used, the expression within the parentheses is
alpar@9: evaluated before the resultant formula is used.
alpar@9: 
alpar@9: The resultant value of the parenthesized expression is the same as the
alpar@9: value of the expression enclosed within parentheses.
alpar@9: 
alpar@9: \subsubsection{Arithmetic operators}
alpar@9: 
alpar@9: In MathProg there exists the following arithmetic operators, which may
alpar@9: be used in linear expressions:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt+} $f$&unary plus\\
alpar@9: {\tt-} $f$&unary minus\\
alpar@9: $f$ {\tt+} $g$&addition\\
alpar@9: $f$ {\tt-} $g$&subtraction\\
alpar@9: $x$ {\tt*} $f$, $f$ {\tt*} $x$&multiplication\\
alpar@9: $f$ {\tt/} $x$&division
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $f$ and $g$ are linear expressions, $x$ is a numeric
alpar@9: expression (more precisely, a linear expression containing only the
alpar@9: constant term).
alpar@9: 
alpar@9: If the expression includes more than one arithmetic operator, all
alpar@9: operators are performed from left to right according to the hierarchy
alpar@9: of operations (see below). The resultant value of the expression, which
alpar@9: contains arithmetic operators, is the result of applying the operators
alpar@9: to their operands.
alpar@9: 
alpar@9: \subsubsection{Hierarchy of operations}
alpar@9: 
alpar@9: The hierarchy of arithmetic operations used in linear expressions is
alpar@9: the same as for numeric expressions (see Subsection \ref{hierarchy},
alpar@9: page \pageref{hierarchy}).
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Statements}
alpar@9: 
alpar@9: {\it Statements} are basic units of the model description. In MathProg
alpar@9: all statements are divided into two categories: declaration statements
alpar@9: and functional statements.
alpar@9: 
alpar@9: {\it Declaration statements} (set statement, parameter statement,
alpar@9: variable statement, constraint statement, and objective statement) are
alpar@9: used to declare model objects of certain kinds and define certain
alpar@9: properties of such objects.
alpar@9: 
alpar@9: {\it Functional statements} (solve statement, check statement, display
alpar@9: statement, printf statement, loop statement) are intended for
alpar@9: performing some specific actions.
alpar@9: 
alpar@9: Note that declaration statements may follow in arbitrary order, which
alpar@9: does not affect the result of translation. However, any model object
alpar@9: must be declared before it is referenced in other statements.
alpar@9: 
alpar@9: \subsection{Set statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][24pt]{345pt}{
alpar@9: \hspace{6pt} {\tt set} {\it name} {\it alias} {\it domain} {\tt,}
alpar@9: {\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: set;
alpar@9: \item[\hspace*{54pt}] {\it alias} is an optional string literal, which
alpar@9: specifies an alias of the set;
alpar@9: \item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
alpar@9: which specifies a subscript domain of the set;
alpar@9: \item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
alpar@9: attributes of the set. (Commae preceding attributes may be omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent Optional attributes:
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\tt dimen} $n$\hspace*{19pt}] specifies the dimension of
alpar@9: $n$-tuples, which the set consists of;
alpar@9: \item[{\tt within} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies a superset which restricts the set or all its members
alpar@9: (elemental sets) to be within that superset;
alpar@9: \item[{\tt:=} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies an elemental set assigned to the set or its members;
alpar@9: \item[{\tt default} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies an elemental set assigned to the set or its members whenever
alpar@9: no appropriate data are available in the data section.
alpar@9: \end{description}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: set V;
alpar@9: set E within V cross V;
alpar@9: set step{s in 1..maxiter} dimen 2 := if s = 1 then E else
alpar@9:    step[s-1] union setof{k in V, (i,k) in step[s-1], (k,j)
alpar@9:    in step[s-1]}(i,j);
alpar@9: set A{i in I, j in J}, within B[i+1] cross C[j-1], within
alpar@9:    D diff E, default {('abc',123), (321,'cba')};
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The set statement declares a set. If the subscript domain is not
alpar@9: specified, the set is a simple set, otherwise it is an array of
alpar@9: elemental sets.
alpar@9: 
alpar@9: The {\tt dimen} attribute specifies the dimension of $n$-tuples, which
alpar@9: the set (if it is a simple set) or its members (if the set is an array
alpar@9: of elemental sets) consist of, where $n$ must be unsigned integer from
alpar@9: 1 to 20. At most one {\tt dimen} attribute can be specified. If the
alpar@9: {\tt dimen} attribute is not specified, the dimension of\linebreak
alpar@9: $n$-tuples is implicitly determined by other attributes (for example,
alpar@9: if there is a set expression that follows {\tt:=} or the keyword
alpar@9: {\tt default}, the dimension of $n$-tuples of corresponding elemental
alpar@9: set is used). If no dimension information is available, {\tt dimen 1}
alpar@9: is assumed.
alpar@9: 
alpar@9: The {\tt within} attribute specifies a set expression whose resultant
alpar@9: value is a superset used to restrict the set (if it is a simple set) or
alpar@9: its members (if the set is an array of elemental sets) to be within
alpar@9: that superset. Arbitrary number of {\tt within} attributes may be
alpar@9: specified in the same set statement.
alpar@9: 
alpar@9: The assign ({\tt:=}) attribute specifies a set expression used to
alpar@9: evaluate elemental set(s) assigned to the set (if it is a simple set)
alpar@9: or its members (if the set is an array of elemental sets). If the
alpar@9: assign attribute is specified, the set is {\it computable} and
alpar@9: therefore needs no data to be provided in the data section. If the
alpar@9: assign attribute is not specified, the set must be provided with data
alpar@9: in the data section. At most one assign or default attribute can be
alpar@9: specified for the same set.
alpar@9: 
alpar@9: The {\tt default} attribute specifies a set expression used to evaluate
alpar@9: elemental set(s) assigned to the set (if it is a simple set) or its
alpar@9: members (if the set is an array of elemental sets) whenever
alpar@9: no appropriate data are available in the data section. If neither
alpar@9: assign nor default attribute is specified, missing data will cause an
alpar@9: error.
alpar@9: 
alpar@9: \subsection{Parameter statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][24pt]{345pt}{
alpar@9: \hspace{6pt} {\tt param} {\it name} {\it alias} {\it domain} {\tt,}
alpar@9: {\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: parameter;
alpar@9: \item[\hspace*{54pt}] {\it alias} is an optional string literal, which
alpar@9: specifies an alias of the parameter;
alpar@9: \item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
alpar@9: which specifies a subscript domain of the parameter;
alpar@9: \item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
alpar@9: attributes of the parameter. (Commae preceding attributes may be
alpar@9: omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent Optional attributes:
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\tt integer}\hspace*{18.5pt}] specifies that the parameter is
alpar@9: integer;
alpar@9: \item[{\tt binary}\hspace*{24pt}] specifies that the parameter is
alpar@9: binary;
alpar@9: \item[{\tt symbolic}\hspace*{13.5pt}] specifies that the parameter is
alpar@9: symbolic;
alpar@9: \item[{\it relation expression}]\hspace*{0pt}\\
alpar@9: (where {\it relation} is one of: {\tt<}, {\tt<=}, {\tt=}, {\tt==},
alpar@9: {\tt>=}, {\tt>}, {\tt<>}, {\tt!=})\\
alpar@9: specifies a condition that restricts the parameter or its members to
alpar@9: satisfy that condition;
alpar@9: \item[{\tt in} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies a superset that restricts the parameter or its members to be
alpar@9: in that superset;
alpar@9: \item[{\tt:=} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies a value assigned to the parameter or its members;
alpar@9: \item[{\tt default} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies a value assigned to the parameter or its members whenever
alpar@9: no appropriate data are available in the data section.
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: param units{raw, prd} >= 0;
alpar@9: param profit{prd, 1..T+1};
alpar@9: param N := 20, integer, >= 0, <= 100;
alpar@9: param comb 'n choose k' {n in 0..N, k in 0..n} :=
alpar@9:    if k = 0 or k = n then 1 else comb[n-1,k-1] + comb[n-1,k];
alpar@9: param p{i in I, j in J}, integer, >= 0, <= i+j,
alpar@9:    in A[i] symdiff B[j], in C[i,j], default 0.5 * (i + j);
alpar@9: param month symbolic default 'May' in {'Mar', 'Apr', 'May'};
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The parameter statement declares a parameter. If a subscript domain is
alpar@9: not specified, the parameter is a simple (scalar) parameter, otherwise
alpar@9: it is a $n$-dimensional array.
alpar@9: 
alpar@9: The type attributes {\tt integer}, {\tt binary}, and {\tt symbolic}
alpar@9: qualify the type of values that can be assigned to the parameter as
alpar@9: shown below:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: Type attribute&Assigned values\\
alpar@9: \hline
alpar@9: (not specified)&Any numeric values\\
alpar@9: {\tt integer}&Only integer numeric values\\
alpar@9: {\tt binary}&Either 0 or 1\\
alpar@9: {\tt symbolic}&Any numeric and symbolic values\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: The {\tt symbolic} attribute cannot be specified along with other type
alpar@9: attributes. Being specified it must precede all other attributes.
alpar@9: 
alpar@9: The condition attribute specifies an optional condition that restricts
alpar@9: values assigned to the parameter to satisfy that condition. This
alpar@9: attribute has the following syntactic forms:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}ll@{}}
alpar@9: {\tt<} $v$&check for $x<v$\\
alpar@9: {\tt<=} $v$&check for $x\leq v$\\
alpar@9: {\tt=} $v$, {\tt==} $v$&check for $x=v$\\
alpar@9: {\tt>=} $v$&check for $x\geq v$\\
alpar@9: {\tt>} $v$&check for $x\geq v$\\
alpar@9: {\tt<>} $v$, {\tt!=} $v$&check for $x\neq v$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $x$ is a value assigned to the parameter, $v$ is the
alpar@9: resultant value of a numeric or symbolic expression specified in the
alpar@9: condition attribute. Arbitrary number of condition attributes can be
alpar@9: specified for the same parameter. If a value being assigned to the
alpar@9: parameter during model evaluation violates at least one of specified
alpar@9: conditions, an error is raised. (Note that symbolic values are ordered
alpar@9: lexicographically, and any numeric value precedes any symbolic value.)
alpar@9: 
alpar@9: The {\tt in} attribute is similar to the condition attribute and
alpar@9: specifies a set expression whose resultant value is a superset used to
alpar@9: restrict numeric or symbolic values assigned to the parameter to be in
alpar@9: that superset. Arbitrary number of the {\tt in} attributes can be
alpar@9: specified for the same parameter. If a value being assigned to the
alpar@9: parameter during model evaluation is not in at least one of specified
alpar@9: supersets, an error is raised.
alpar@9: 
alpar@9: The assign ({\tt:=}) attribute specifies a numeric or symbolic
alpar@9: expression used to compute a value assigned to the parameter (if it is
alpar@9: a simple parameter) or its member (if the parameter is an array). If
alpar@9: the assign attribute is specified, the parameter is {\it computable}
alpar@9: and therefore needs no data to be provided in the data section. If the
alpar@9: assign attribute is not specified, the parameter must be provided with
alpar@9: data in the data section. At most one assign or {\tt default} attribute
alpar@9: can be specified for the same parameter.
alpar@9: 
alpar@9: The {\tt default} attribute specifies a numeric or symbolic expression
alpar@9: used to compute a value assigned to the parameter or its member
alpar@9: whenever no appropriate data are available in the data section. If
alpar@9: neither assign nor {\tt default} attribute is specified, missing data
alpar@9: will cause an error.
alpar@9: 
alpar@9: \subsection{Variable statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][24pt]{345pt}{
alpar@9: \hspace{6pt} {\tt var} {\it name} {\it alias} {\it domain} {\tt,}
alpar@9: {\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: variable;
alpar@9: \item[\hspace*{54pt}] {\it alias} is an optional string literal, which
alpar@9: specifies an alias of the variable;
alpar@9: \item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
alpar@9: which specifies a subscript domain of the variable;
alpar@9: \item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
alpar@9: attributes of the variable. (Commae preceding attributes may be
alpar@9: omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent Optional attributes:
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\tt integer}\hspace*{18.5pt}] restricts the variable to be
alpar@9: integer;
alpar@9: \item[{\tt binary}\hspace*{24pt}] restricts the variable to be binary;
alpar@9: \item[{\tt>=} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies an lower bound of the variable;
alpar@9: \item[{\tt<=} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies an upper bound of the variable;
alpar@9: \item[{\tt=} {\it expression}]\hspace*{0pt}\\
alpar@9: specifies a fixed value of the variable;
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: var x >= 0;
alpar@9: var y{I,J};
alpar@9: var make{p in prd}, integer, >= commit[p], <= market[p];
alpar@9: var store{raw, 1..T+1} >= 0;
alpar@9: var z{i in I, j in J} >= i+j;
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The variable statement declares a variable. If a subscript domain is
alpar@9: not specified, the variable is a simple (scalar) variable, otherwise it
alpar@9: is a $n$-dimensional array of elemental variables.
alpar@9: 
alpar@9: Elemental variable(s) associated with the model variable (if it is a
alpar@9: simple variable) or its members (if it is an array) correspond to the
alpar@9: variables in the LP/MIP problem formulation (see Subsection
alpar@9: \ref{problem}, page \pageref{problem}). Note that only elemental
alpar@9: variables actually referenced in some constraints and/or objectives are
alpar@9: included in the LP/MIP problem instance to be generated.
alpar@9: 
alpar@9: The type attributes {\tt integer} and {\tt binary} restrict the
alpar@9: variable to be integer or binary, respectively. If no type attribute is
alpar@9: specified, the variable is continuous. If all variables in the model
alpar@9: are continuous, the corresponding problem is of LP class. If there is
alpar@9: at least one integer or binary variable, the problem is of MIP class.
alpar@9: 
alpar@9: The lower bound ({\tt>=}) attribute specifies a numeric expression for
alpar@9: computing an lower bound of the variable. At most one lower bound can
alpar@9: be specified. By default all variables (except binary ones) have no
alpar@9: lower bound, so if a variable is required to be non-negative, its zero
alpar@9: lower bound should be explicitly specified.
alpar@9: 
alpar@9: The upper bound ({\tt<=}) attribute specifies a numeric expression for
alpar@9: computing an upper bound of the variable. At most one upper bound
alpar@9: attribute can be specified.
alpar@9: 
alpar@9: The fixed value ({\tt=}) attribute specifies a numeric expression for
alpar@9: computing a value, at which the variable is fixed. This attribute
alpar@9: cannot be specified along with the bound attributes.
alpar@9: 
alpar@9: \subsection{Constraint statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][96pt]{345pt}{
alpar@9: \hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
alpar@9: {\it expression} {\tt,} {\tt=} {\it expression} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
alpar@9: {\it expression} {\tt,} {\tt<=} {\it expression} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
alpar@9: {\it expression} {\tt,} {\tt>=} {\it expression} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
alpar@9: {\it expression} {\tt,} {\tt<=} {\it expression} {\tt,} {\tt<=}
alpar@9: {\it expression} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
alpar@9: {\it expression} {\tt,} {\tt>=} {\it expression} {\tt,} {\tt>=}
alpar@9: {\it expression} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: constraint;
alpar@9: \item[\hspace*{54pt}] {\it alias} is an optional string literal, which
alpar@9: specifies an alias of the constraint;
alpar@9: \item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
alpar@9: which specifies a subscript domain of the constraint;
alpar@9: \item[\hspace*{54pt}] {\it expression} is a linear expression used to
alpar@9: compute a component of the constraint. (Commae following expressions
alpar@9: may be omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Note:}\hspace*{31pt}] The keyword {\tt s.t.} may be written
alpar@9: as {\tt subject to} or as {\tt subj to}, or may be omitted at all.
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: s.t. r: x + y + z, >= 0, <= 1;
alpar@9: limit{t in 1..T}: sum{j in prd} make[j,t] <= max_prd;
alpar@9: subject to balance{i in raw, t in 1..T}: store[i,t+1] -
alpar@9:    store[i,t] - sum{j in prd} units[i,j] * make[j,t];
alpar@9: subject to rlim 'regular-time limit' {t in time}:
alpar@9: sum{p in prd} pt[p] * rprd[p,t] <= 1.3 * dpp[t] * crews[t];
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The constraint statement declares a constraint. If a subscript domain
alpar@9: is not specified, the constraint is a simple (scalar) constraint,
alpar@9: otherwise it is a $n$-dimensional array of elemental constraints.
alpar@9: 
alpar@9: Elemental constraint(s) associated with the model constraint (if it is
alpar@9: a simple constraint) or its members (if it is an array) correspond to
alpar@9: the linear constraints in the LP/MIP problem formulation (see
alpar@9: Subsection \ref{problem}, page \pageref{problem}).
alpar@9: 
alpar@9: If the constraint has the form of equality or single inequality, i.e.
alpar@9: includes two expressions, one of which follows the colon and other
alpar@9: follows the relation sign {\tt=}, {\tt<=}, or {\tt>=}, both expressions
alpar@9: in the statement can be linear expressions. If the constraint has the
alpar@9: form of double inequality, i.e. includes three expressions, the middle
alpar@9: expression can be a linear expression while the leftmost and rightmost
alpar@9: ones can be only numeric expressions.
alpar@9: 
alpar@9: Generating the model is, roughly speaking, generating its constraints,
alpar@9: which are always evaluated for the entire subscript domain. Evaluation
alpar@9: of the constraints leads, in turn, to evaluation of other model objects
alpar@9: such as sets, parameters, and variables.
alpar@9: 
alpar@9: Constructing an actual linear constraint included in the problem
alpar@9: instance, which (constraint) corresponds to a particular elemental
alpar@9: constraint, is performed as follows.
alpar@9: 
alpar@9: If the constraint has the form of equality or single inequality,
alpar@9: evaluation of both linear expressions gives two resultant linear forms:
alpar@9: $$\begin{array}{r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r}
alpar@9: f&=&a_1x_1&+&a_2x_2&+\dots+&a_nx_n&+&a_0,\\
alpar@9: g&=&b_1x_1&+&a_2x_2&+\dots+&a_nx_n&+&b_0,\\
alpar@9: \end{array}$$
alpar@9: where $x_1$, $x_2$, \dots, $x_n$ are elemental variables; $a_1$, $a_2$,
alpar@9: \dots, $a_n$, $b_1$, $b_2$, \dots, $b_n$ are numeric coefficients;
alpar@9: $a_0$ and $b_0$ are constant terms. Then all linear terms of $f$ and
alpar@9: $g$ are carried to the left-hand side, and the constant terms are
alpar@9: carried to the right-hand side, that gives the final elemental
alpar@9: constraint in the standard form:
alpar@9: $$(a_1-b_1)x_1+(a_2-b_2)x_2+\dots+(a_n-b_n)x_n\left\{
alpar@9: \begin{array}{@{}c@{}}=\\\leq\\\geq\\\end{array}\right\}b_0-a_0.$$
alpar@9: 
alpar@9: If the constraint has the form of double inequality, evaluation of the
alpar@9: middle linear expression gives the resultant linear form:
alpar@9: $$f=a_1x_1+a_2x_2+\dots+a_nx_n+a_0,$$
alpar@9: and evaluation of the leftmost and rightmost numeric expressions gives
alpar@9: two numeric values $l$ and $u$, respectively. Then the constant term of
alpar@9: the linear form is carried to both left-hand and right-handsides that
alpar@9: gives the final elemental constraint in the standard form:
alpar@9: $$l-a_0\leq a_1x_1+a_2x_2+\dots+a_nx_n\leq u-a_0.$$
alpar@9: 
alpar@9: \subsection{Objective statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][44pt]{345pt}{
alpar@9: \hspace{6pt} {\tt minimize} {\it name} {\it alias} {\it domain} {\tt:}
alpar@9: {\it expression} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt maximize} {\it name} {\it alias} {\it domain} {\tt:}
alpar@9: {\it expression} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: objective;
alpar@9: \item[\hspace*{54pt}] {\it alias} is an optional string literal, which
alpar@9: specifies an alias of the objective;
alpar@9: \item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
alpar@9: which specifies a subscript domain of the objective;
alpar@9: \item[\hspace*{54pt}] {\it expression} is a linear expression used to
alpar@9: compute the linear form of the objective.
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: minimize obj: x + 1.5 * (y + z);
alpar@9: maximize total_profit: sum{p in prd} profit[p] * make[p];
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The objective statement declares an objective. If a subscript domain is
alpar@9: not specified, the objective is a simple (scalar) objective. Otherwise
alpar@9: it is a $n$-dimensional array of elemental objectives.
alpar@9: 
alpar@9: Elemental objective(s) associated with the model objective (if it is a
alpar@9: simple objective) or its members (if it is an array) correspond to
alpar@9: general linear constraints in the LP/MIP problem formulation (see
alpar@9: Subsection \ref{problem}, page \pageref{problem}). However, unlike
alpar@9: constraints the corresponding linear forms are free (unbounded).
alpar@9: 
alpar@9: Constructing an actual linear constraint included in the problem
alpar@9: instance, which (constraint) corresponds to a particular elemental
alpar@9: constraint, is performed as follows. The linear expression specified in
alpar@9: the objective statement is evaluated that, gives the resultant linear
alpar@9: form:
alpar@9: $$f=a_1x_1+a_2x_2+\dots+a_nx_n+a_0,$$
alpar@9: where $x_1$, $x_2$, \dots, $x_n$ are elemental variables; $a_1$, $a_2$,
alpar@9: \dots, $a_n$ are numeric coefficients; $a_0$ is the constant term. Then
alpar@9: the linear form is used to construct the final elemental constraint in
alpar@9: the standard form:
alpar@9: $$-\infty<a_1x_1+a_2x_2+\dots+a_nx_n+a_0<+\infty.$$
alpar@9: 
alpar@9: As a rule the model description contains only one objective statement
alpar@9: that defines the objective function used in the problem instance.
alpar@9: However, it is allowed to declare arbitrary number of objectives, in
alpar@9: which case the actual objective function is the first objective
alpar@9: encountered in the model description. Other objectives are also
alpar@9: included in the problem instance, but they do not affect the objective
alpar@9: function.
alpar@9: 
alpar@9: \subsection{Solve statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][24pt]{345pt}{
alpar@9: \hspace{6pt} {\tt solve} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Note:}\hspace*{31pt}] The solve statement is optional and
alpar@9: can be used only once. If no solve statement is used, one is assumed at
alpar@9: the end of the model section.
alpar@9: \end{description}
alpar@9: 
alpar@9: The solve statement causes the model to be solved, that means computing
alpar@9: numeric values of all model variables. This allows using variables in
alpar@9: statements below the solve statement in the same way as if they were
alpar@9: numeric parameters.
alpar@9: 
alpar@9: Note that the variable, constraint, and objective statements cannot be
alpar@9: used below the solve statement, i.e. all principal components of the
alpar@9: model must be declared above the solve statement.
alpar@9: 
alpar@9: \subsection{Check statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][24pt]{345pt}{
alpar@9: \hspace{6pt} {\tt check} {\it domain} {\tt:} {\it expression} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
alpar@9: expression, which specifies a subscript domain of the check statement;
alpar@9: \item[\hspace*{54pt}] {\it expression} is an logical expression which
alpar@9: specifies the logical condition to be checked. (The colon preceding
alpar@9: {\it expression} may be omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: check: x + y <= 1 and x >= 0 and y >= 0;
alpar@9: check sum{i in ORIG} supply[i] = sum{j in DEST} demand[j];
alpar@9: check{i in I, j in 1..10}: S[i,j] in U[i] union V[j];
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The check statement allows checking the resultant value of an logical
alpar@9: expression specified in the statement. If the value is {\it false}, an
alpar@9: error is reported.
alpar@9: 
alpar@9: If the subscript domain is not specified, the check is performed only
alpar@9: once. Specifying the subscript domain allows performing multiple checks
alpar@9: for every\linebreak $n$-tuple in the domain set. In the latter case the
alpar@9: logical expression may include dummy indices introduced in
alpar@9: corresponding indexing expression.
alpar@9: 
alpar@9: \subsection{Display statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][24pt]{345pt}{
alpar@9: \hspace{6pt} {\tt display} {\it domain} {\tt:} {\it item} {\tt,}
alpar@9: \dots {\tt,} {\it item} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
alpar@9: expression, which specifies a subscript domain of the check statement;
alpar@9: \item[\hspace*{54pt}] {\it item}, \dots, {\it item} are items to be
alpar@9: displayed. (The colon preceding the first item may be omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: display: 'x =', x, 'y =', y, 'z =', z;
alpar@9: display sqrt(x ** 2 + y ** 2 + z ** 2);
alpar@9: display{i in I, j in J}: i, j, a[i,j], b[i,j];
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: The display statement evaluates all items specified in the statement
alpar@9: and writes their values to the terminal in plain text format.
alpar@9: 
alpar@9: If a subscript domain is not specified, items are evaluated and then
alpar@9: displayed only once. Specifying the subscript domain causes items to be
alpar@9: evaluated and displayed for every $n$-tuple in the domain set. In the
alpar@9: latter case items may include dummy indices introduced in corresponding
alpar@9: indexing expression.
alpar@9: 
alpar@9: An item to be displayed can be a model object (set, parameter, variable,
alpar@9: constraint, objective) or an expression.
alpar@9: 
alpar@9: If the item is a computable object (i.e. a set or parameter provided
alpar@9: with the assign attribute), the object is evaluated over the entire
alpar@9: domain and then its content (i.e. the content of the object array) is
alpar@9: displayed. Otherwise, if the item is not a computable object, only its
alpar@9: current content (i.e. members actually generated during the model
alpar@9: evaluation) is displayed.
alpar@9: 
alpar@9: If the item is an expression, the expression is evaluated and its
alpar@9: resultant value is displayed.
alpar@9: 
alpar@9: \subsection{Printf statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][60pt]{345pt}{
alpar@9: \hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
alpar@9: {\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
alpar@9: {\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt>}
alpar@9: {\it filename} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
alpar@9: {\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt>>}
alpar@9: {\it filename} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
alpar@9: expression, which specifies a subscript domain of the printf statement;
alpar@9: \item[\hspace*{54pt}] {\it format} is a symbolic expression whose value
alpar@9: specifies a format control string. (The colon preceding the format
alpar@9: expression may be omitted.)
alpar@9: \item[\hspace*{54pt}] {\it expression}, \dots, {\it expression} are
alpar@9: zero or more expressions whose values have to be formatted and printed.
alpar@9: Each expression must be of numeric, symbolic, or logical type.
alpar@9: \item[\hspace*{54pt}] {\it filename} is a symbolic expression whose
alpar@9: value specifies a name of a text file, to which the output is
alpar@9: redirected. The flag {\tt>} means creating a new empty file while the
alpar@9: flag {\tt>>} means appending the output to an existing file. If no file
alpar@9: name is specified, the output is written to the terminal.
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: printf 'Hello, world!\n';
alpar@9: printf: "x = %.3f; y = %.3f; z = %.3f\n",
alpar@9:    x, y, z > "result.txt";
alpar@9: printf{i in I, j in J}: "flow from %s to %s is %d\n",
alpar@9:    i, j, x[i,j] >> result_file & ".txt";
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: printf{i in I} 'total flow from %s is %g\n',
alpar@9:    i, sum{j in J} x[i,j];
alpar@9: printf{k in K} "x[%s] = " & (if x[k] < 0 then "?" else "%g"),
alpar@9:    k, x[k];
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The printf statement is similar to the display statement, however, it
alpar@9: allows formatting data to be written.
alpar@9: 
alpar@9: If a subscript domain is not specified, the printf statement is
alpar@9: executed only once. Specifying a subscript domain causes executing the
alpar@9: printf statement for every $n$-tuple in the domain set. In the latter
alpar@9: case the format and expression may include dummy indices introduced in
alpar@9: corresponding indexing expression.
alpar@9: 
alpar@9: The format control string is a value of the symbolic expression
alpar@9: {\it format} specified in the printf statement. It is composed of zero
alpar@9: or more directives as follows: ordinary characters (not {\tt\%}), which
alpar@9: are copied unchanged to the output stream, and conversion
alpar@9: specifications, each of which causes evaluating corresponding
alpar@9: expression specified in the printf statement, formatting it, and
alpar@9: writing its resultant value to the output stream.
alpar@9: 
alpar@9: Conversion specifications that may be used in the format control string
alpar@9: are the following: {\tt d}, {\tt i}, {\tt f}, {\tt F}, {\tt e}, {\tt E},
alpar@9: {\tt g}, {\tt G}, and {\tt s}. These specifications have the same
alpar@9: syntax and semantics as in the C programming language.
alpar@9: 
alpar@9: \subsection{For statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][44pt]{345pt}{
alpar@9: \hspace{6pt} {\tt for} {\it domain} {\tt:} {\it statement} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt for} {\it domain} {\tt:} {\tt\{} {\it statement}
alpar@9: \dots {\it statement} {\tt\}} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it domain} is an indexing
alpar@9: expression which specifies a subscript domain of the for statement.
alpar@9: (The colon following the indexing expression may be omitted.)
alpar@9: \item[\hspace*{54pt}] {\it statement} is a statement, which should be
alpar@9: executed under control of the for statement;
alpar@9: \item[\hspace*{54pt}] {\it statement}, \dots, {\it statement} is a
alpar@9: sequence of statements (enclosed in curly braces), which should be
alpar@9: executed under control of the for statement.
alpar@9: \end{description}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Note:}\hspace*{31pt}] Only the following statements can be
alpar@9: used within the for statement: check, display, printf, and another for.
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: for {(i,j) in E: i != j}
alpar@9: {  printf "flow from %s to %s is %g\n", i, j, x[i,j];
alpar@9:    check x[i,j] >= 0;
alpar@9: }
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: for {i in 1..n}
alpar@9: {  for {j in 1..n} printf " %s", if x[i,j] then "Q" else ".";
alpar@9:    printf("\n");
alpar@9: }
alpar@9: for {1..72} printf("*");
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The for statement causes a statement or a sequence of statements
alpar@9: specified as part of the for statement to be executed for every
alpar@9: $n$-tuple in the domain set. Thus, statements within the for statement
alpar@9: may include dummy indices introduced in corresponding indexing
alpar@9: expression.
alpar@9: 
alpar@9: \subsection{Table statement}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][68pt]{345pt}{
alpar@9: \hspace{6pt} {\tt table} {\it name} {\it alias} {\tt IN} {\it driver}
alpar@9: {\it arg} \dots {\it arg} {\tt:}
alpar@9: 
alpar@9: \hspace{6pt} {\tt\ \ \ \ \ } {\it set} {\tt<-} {\tt[} {\it fld} {\tt,}
alpar@9: \dots {\tt,} {\it fld} {\tt]} {\tt,} {\it par} {\tt\textasciitilde}
alpar@9: {\it fld} {\tt,} \dots {\tt,} {\it par} {\tt\textasciitilde} {\it fld}
alpar@9: {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt table} {\it name} {\it alias} {\it domain} {\tt OUT}
alpar@9: {\it driver} {\it arg} \dots {\it arg} {\tt:}
alpar@9: 
alpar@9: \hspace{6pt} {\tt\ \ \ \ \ } {\it expr} {\tt\textasciitilde} {\it fld}
alpar@9: {\tt,} \dots {\tt,} {\it expr} {\tt\textasciitilde} {\it fld} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: table;
alpar@9: \item[\hspace*{54pt}] {\it alias} is an optional string literal, which
alpar@9: specifies an alias of the table;
alpar@9: \item[\hspace*{54pt}] {\it domain} is an indexing expression, which
alpar@9: specifies a subscript domain of the (output) table;
alpar@9: \item[\hspace*{54pt}] {\tt IN} means reading data from the input table;
alpar@9: \item[\hspace*{54pt}] {\tt OUT} means writing data to the output table;
alpar@9: \item[\hspace*{54pt}] {\it driver} is a symbolic expression, which
alpar@9: specifies the driver used to access the table (for details see Section
alpar@9: \ref{drivers}, page \pageref{drivers});
alpar@9: \item[\hspace*{54pt}] {\it arg} is an optional symbolic expression,
alpar@9: which is an argument pass\-ed to the table driver. This symbolic
alpar@9: expression must not include dummy indices specified in the domain;
alpar@9: \item[\hspace*{54pt}] {\it set} is the name of an optional simple set
alpar@9: called {\it control set}. It can be omitted along with the delimiter
alpar@9: {\tt<-};
alpar@9: \item[\hspace*{54pt}] {\it fld} is a field name. Within square brackets
alpar@9: at least one field should be specified. The field name following
alpar@9: a parameter name or expression is optional and can be omitted along
alpar@9: with the delimiter {\tt\textasciitilde}, in which case the name of
alpar@9: corresponding model object is used as the field name;
alpar@9: \item[\hspace*{54pt}] {\it par} is a symbolic name of a model parameter;
alpar@9: \item[\hspace*{54pt}] {\it expr} is a numeric or symbolic expression.
alpar@9: \end{description}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: table data IN "CSV" "data.csv":
alpar@9:    S <- [FROM,TO], d~DISTANCE, c~COST;
alpar@9: table result{(f,t) in S} OUT "CSV" "result.csv":
alpar@9:    f~FROM, t~TO, x[f,t]~FLOW;
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The table statement allows reading data from a table into model
alpar@9: objects such as sets and (non-scalar) parameters as well as writing
alpar@9: data from the model to a table.
alpar@9: 
alpar@9: \subsubsection{Table structure}
alpar@9: 
alpar@9: A {\it data table} is an (unordered) set of {\it records}, where each
alpar@9: record consists of the same number of {\it fields}, and each field is
alpar@9: provided with a unique symbolic name called the {\it field name}. For
alpar@9: example:
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: \begin{tabular}{@{\hspace*{38mm}}c@{\hspace*{11mm}}c@{\hspace*{10mm}}c
alpar@9: @{\hspace*{9mm}}c}
alpar@9: First&Second&&Last\\
alpar@9: field&field&.\ \ .\ \ .&field\\
alpar@9: $\downarrow$&$\downarrow$&&$\downarrow$\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \begin{tabular}{ll@{}}
alpar@9: Table header&$\rightarrow$\\
alpar@9: First record&$\rightarrow$\\
alpar@9: Second record&$\rightarrow$\\
alpar@9: \\
alpar@9: \hfil .\ \ .\ \ .\\
alpar@9: \\
alpar@9: Last record&$\rightarrow$\\
alpar@9: \end{tabular}
alpar@9: \begin{tabular}{|l|l|c|c|}
alpar@9: \hline
alpar@9: {\tt FROM}&{\tt TO}&{\tt DISTANCE}&{\tt COST}\\
alpar@9: \hline
alpar@9: {\tt Seattle}  &{\tt New-York}&{\tt 2.5}&{\tt 0.12}\\
alpar@9: {\tt Seattle}  &{\tt Chicago} &{\tt 1.7}&{\tt 0.08}\\
alpar@9: {\tt Seattle}  &{\tt Topeka}  &{\tt 1.8}&{\tt 0.09}\\
alpar@9: {\tt San-Diego}&{\tt New-York}&{\tt 2.5}&{\tt 0.15}\\
alpar@9: {\tt San-Diego}&{\tt Chicago} &{\tt 1.8}&{\tt 0.10}\\
alpar@9: {\tt San-Diego}&{\tt Topeka}  &{\tt 1.4}&{\tt 0.07}\\
alpar@9: \hline
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \subsubsection{Reading data from input table}
alpar@9: 
alpar@9: The input table statement causes reading data from the specified table
alpar@9: record by record.
alpar@9: 
alpar@9: Once a next record has been read, numeric or symbolic values of fields,
alpar@9: whose names are enclosed in square brackets in the table statement, are
alpar@9: gathered into $n$-tuple, and if the control set is specified in the
alpar@9: table statement, this $n$-tuple is added to it. Besides, a numeric or
alpar@9: symbolic value of each field associated with a model parameter is
alpar@9: assigned to the parameter member identified by subscripts, which are
alpar@9: components of the $n$-tuple just read.
alpar@9: 
alpar@9: For example, the following input table statement:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \verb|table data IN "...": S <- [FROM,TO], d~DISTANCE, c~COST;|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: causes reading values of four fields named {\tt FROM}, {\tt TO},
alpar@9: {\tt DISTANCE}, and {\tt COST} from each record of the specified table.
alpar@9: Values of fields {\tt FROM} and {\tt TO} give a pair $(f,t)$, which is
alpar@9: added to the control set {\tt S}. The value of field {\tt DISTANCE} is
alpar@9: assigned to parameter member ${\tt d}[f,t]$, and the value of field
alpar@9: {\tt COST} is assigned to parameter member ${\tt c}[f,t]$.
alpar@9: 
alpar@9: Note that the input table may contain extra fields whose names are not
alpar@9: specified in the table statement, in which case values of these fields
alpar@9: on reading the table are ignored.
alpar@9: 
alpar@9: \subsubsection{Writing data to output table}
alpar@9: 
alpar@9: The output table statement causes writing data to the specified table.
alpar@9: Note that some drivers (namely, CSV and xBASE) destroy the output table
alpar@9: before writing data, i.e. delete all its existing records.
alpar@9: 
alpar@9: Each $n$-tuple in the specified domain set generates one record written
alpar@9: to the output table. Values of fields are numeric or symbolic values of
alpar@9: corresponding expressions specified in the table statement. These
alpar@9: expressions are evaluated for each $n$-tuple in the domain set and,
alpar@9: thus, may include dummy indices introduced in the corresponding indexing
alpar@9: expression.
alpar@9: 
alpar@9: For example, the following output table statement:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: \verb|   table result{(f,t) in S} OUT "...": f~FROM, t~TO, x[f,t]~FLOW;|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: causes writing records, by one record for each pair $(f,t)$ in set
alpar@9: {\tt S}, to the output table, where each record consists of three
alpar@9: fields named {\tt FROM}, {\tt TO}, and {\tt FLOW}. The values written
alpar@9: to fields {\tt FROM} and {\tt TO} are current values of dummy indices
alpar@9: {\tt f} and {\tt t}, and the value written to field {\tt FLOW} is
alpar@9: a value of member ${\tt x}[f,t]$ of corresponding subscripted parameter
alpar@9: or variable.
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Model data}
alpar@9: 
alpar@9: {\it Model data} include elemental sets, which are ``values'' of model
alpar@9: sets, and numeric and symbolic values of model parameters.
alpar@9: 
alpar@9: In MathProg there are two different ways to saturate model sets and
alpar@9: parameters with data. One way is simply providing necessary data using
alpar@9: the assign attribute. However, in many cases it is more practical to
alpar@9: separate the model itself and particular data needed for the model. For
alpar@9: the latter reason in MathProg there is another way, when the model
alpar@9: description is divided into two parts: model section and data section.
alpar@9: 
alpar@9: A {\it model section} is a main part of the model description that
alpar@9: contains declarations of all model objects and is common for all
alpar@9: problems based on that model.
alpar@9: 
alpar@9: A {\it data section} is an optional part of the model description that
alpar@9: contains model data specific for a particular problem.
alpar@9: 
alpar@9: In MathProg model and data sections can be placed either in one text
alpar@9: file or in two separate text files.
alpar@9: 
alpar@9: 1. If both model and data sections are placed in one file, the file is
alpar@9: composed as follows:
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \framebox{\begin{tabular}{l}
alpar@9: {\it statement}{\tt;}\\
alpar@9: {\it statement}{\tt;}\\
alpar@9: \hfil.\ \ .\ \ .\\
alpar@9: {\it statement}{\tt;}\\
alpar@9: {\tt data;}\\
alpar@9: {\it data block}{\tt;}\\
alpar@9: {\it data block}{\tt;}\\
alpar@9: \hfil.\ \ .\ \ .\\
alpar@9: {\it data block}{\tt;}\\
alpar@9: {\tt end;}
alpar@9: \end{tabular}}
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: 2. If the model and data sections are placed in two separate files, the
alpar@9: files are composed as follows:
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: \begin{tabular}{@{}c@{}}
alpar@9: \framebox{\begin{tabular}{l}
alpar@9: {\it statement}{\tt;}\\
alpar@9: {\it statement}{\tt;}\\
alpar@9: \hfil.\ \ .\ \ .\\
alpar@9: {\it statement}{\tt;}\\
alpar@9: {\tt end;}\\
alpar@9: \end{tabular}}\\
alpar@9: \\\\Model file\\
alpar@9: \end{tabular}
alpar@9: \hspace{32pt}
alpar@9: \begin{tabular}{@{}c@{}}
alpar@9: \framebox{\begin{tabular}{l}
alpar@9: {\tt data;}\\
alpar@9: {\it data block}{\tt;}\\
alpar@9: {\it data block}{\tt;}\\
alpar@9: \hfil.\ \ .\ \ .\\
alpar@9: {\it data block}{\tt;}\\
alpar@9: {\tt end;}\\
alpar@9: \end{tabular}}\\
alpar@9: \\Data file\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Note:}\hspace*{31pt}] If the data section is placed in a
alpar@9: separate file, the keyword {\tt data} is optional and may be omitted
alpar@9: along with the semicolon that follows it.
alpar@9: \end{description}
alpar@9: 
alpar@9: \subsection{Coding data section}
alpar@9: 
alpar@9: The {\it data section} is a sequence of data blocks in various formats,
alpar@9: which are discussed in following subsections. The order, in which data
alpar@9: blocks follow in the data section, may be arbitrary, not necessarily
alpar@9: the same, in which corresponding model objects follow in the model
alpar@9: section.
alpar@9: 
alpar@9: The rules of coding the data section are commonly the same as the rules
alpar@9: of coding the model description (see Subsection \ref{coding}, page
alpar@9: \pageref{coding}), i.e. data blocks are composed from basic lexical
alpar@9: units such as symbolic names, numeric and string literals, keywords,
alpar@9: delimiters, and comments. However, for the sake of convenience and
alpar@9: improving readability there is one deviation from the common rule: if
alpar@9: a string literal consists of only alphanumeric characters (including
alpar@9: the underscore character), the signs {\tt+} and {\tt-}, and/or the
alpar@9: decimal point, it may be coded without bordering by (single or double)
alpar@9: quotes.
alpar@9: 
alpar@9: All numeric and symbolic material provided in the data section is coded
alpar@9: in the form of numbers and symbols, i.e. unlike the model section
alpar@9: no expressions are allowed in the data section. Nevertheless, the signs
alpar@9: {\tt+} and {\tt-} can precede numeric literals to allow coding signed
alpar@9: numeric quantities, in which case there must be no white-space
alpar@9: characters between the sign and following numeric literal (if there is
alpar@9: at least one white-space, the sign and following numeric literal are
alpar@9: recognized as two different lexical units).
alpar@9: 
alpar@9: \subsection{Set data block}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][44pt]{345pt}{
alpar@9: \hspace{6pt} {\tt set} {\it name} {\tt,} {\it record} {\tt,} \dots
alpar@9: {\tt,} {\it record} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt set} {\it name} {\tt[} {\it symbol} {\tt,} \dots
alpar@9: {\tt,} {\it symbol} {\tt]} {\tt,} {\it record} {\tt,} \dots {\tt,}
alpar@9: {\it record} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: set;
alpar@9: \item[\hspace*{54pt}] {\it symbol}, \dots, {\it symbol} are subscripts,
alpar@9: which specify a particular member of the set (if the set is an array,
alpar@9: i.e. a set of sets);
alpar@9: \item[\hspace*{54pt}] {\it record}, \dots, {\it record} are data
alpar@9: records.
alpar@9: \end{description}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Note:}\hspace*{31pt}] Commae preceding data records may be
alpar@9: omitted.
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent Data records:
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\tt :=}\hspace*{45pt}] is a non-significant data record, which
alpar@9: may be used freely to improve readability;
alpar@9: \item[{\tt(} {\it slice} {\tt)}\hspace*{18.5pt}] specifies a slice;
alpar@9: \item[{\it simple-data}\hspace*{5.5pt}] specifies set data in the
alpar@9: simple format;
alpar@9: \item[{\tt:} {\it matrix-data}]\hspace*{0pt}\\
alpar@9: specifies set data in the matrix format;
alpar@9: \item[{\tt(tr)} {\tt:} {\it matrix-data}]\hspace*{0pt}\\
alpar@9: specifies set data in the transposed matrix format. (In this case the
alpar@9: colon following the keyword {\tt(tr)} may be omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: set month := Jan Feb Mar Apr May Jun;
alpar@9: set month "Jan", "Feb", "Mar", "Apr", "May", "Jun";
alpar@9: set A[3,Mar] := (1,2) (2,3) (4,2) (3,1) (2,2) (4,4) (3,4);
alpar@9: set A[3,'Mar'] := 1 2 2 3 4 2 3 1 2 2 4 4 2 4;
alpar@9: set A[3,'Mar'] : 1 2 3 4 :=
alpar@9:                1 - + - -
alpar@9:                2 - + + -
alpar@9:                3 + - - +
alpar@9:                4 - + - + ;
alpar@9: set B := (1,2,3) (1,3,2) (2,3,1) (2,1,3) (1,2,2) (1,1,1) (2,1,1);
alpar@9: set B := (*,*,*) 1 2 3, 1 3 2, 2 3 1, 2 1 3, 1 2 2, 1 1 1, 2 1 1;
alpar@9: set B := (1,*,2) 3 2 (2,*,1) 3 1 (1,2,3) (2,1,3) (1,1,1);
alpar@9: set B := (1,*,*) : 1 2 3 :=
alpar@9:                  1 + - -
alpar@9:                  2 - + +
alpar@9:                  3 - + -
alpar@9:          (2,*,*) : 1 2 3 :=
alpar@9:                  1 + - +
alpar@9:                  2 - - -
alpar@9:                  3 + - - ;
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \noindent(In these examples {\tt month} is a simple set of singlets,
alpar@9: {\tt A} is a 2-dimensional array of doublets, and {\tt B} is a simple
alpar@9: set of triplets. Data blocks for the same set are equivalent in the
alpar@9: sense that they specify the same data in different formats.)
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: The {\it set data block} is used to specify a complete elemental set,
alpar@9: which is assigned to a set (if it is a simple set) or one of its
alpar@9: members (if the set is an array of sets).\footnote{There is another way
alpar@9: to specify data for a simple set along with data for parameters. This
alpar@9: feature is discussed in the next subsection.}
alpar@9: 
alpar@9: Data blocks can be specified only for non-computable sets, i.e. for
alpar@9: sets, which have no assign ({\tt:=}) attribute in the corresponding set
alpar@9: statements.
alpar@9: 
alpar@9: If the set is a simple set, only its symbolic name should be specified
alpar@9: in the header of the data block. Otherwise, if the set is a
alpar@9: $n$-dimensional array, its symbolic name should be provided with a
alpar@9: complete list of subscripts separated by commae and enclosed in square
alpar@9: brackets to specify a particular member of the set array. The number of
alpar@9: subscripts must be the same as the dimension of the set array, where
alpar@9: each subscript must be a number or symbol.
alpar@9: 
alpar@9: An elemental set defined in the set data block is coded as a sequence
alpar@9: of data records described below.\footnote{{\it Data record} is simply a
alpar@9: technical term. It does not mean that data records have any special
alpar@9: formatting.}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \subsubsection{Assign data record}
alpar@9: 
alpar@9: The {\it assign} ({\tt:=}) {\it data record} is a non-signficant
alpar@9: element. It may be used for improving readability of data blocks.
alpar@9: 
alpar@9: \subsubsection{Slice data record}
alpar@9: 
alpar@9: The {\it slice data record} is a control record, which specifies a
alpar@9: {\it slice} of the elemental set defined in the data block. It has the
alpar@9: following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt(} $s_1$ {\tt,} $s_2$ {\tt,} \dots {\tt,} $s_n$ {\tt)}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $s_1$, $s_2$, \dots, $s_n$ are components of the slice.
alpar@9: 
alpar@9: Each component of the slice can be a number or symbol or the asterisk
alpar@9: ({\tt*}). The number of components in the slice must be the same as the
alpar@9: dimension of $n$-tuples in the elemental set to be defined. For
alpar@9: instance, if the elemental set contains 4-tuples (quadruplets), the
alpar@9: slice must have four components. The number of asterisks in the slice
alpar@9: is called the {\it slice dimension}.
alpar@9: 
alpar@9: The effect of using slices is the following. If a $m$-dimensional slice
alpar@9: (i.e. a slice having $m$ asterisks) is specified in the data block, all
alpar@9: subsequent data records must specify tuples of the dimension $m$.
alpar@9: Whenever a $m$-tuple is encountered, each asterisk in the slice is
alpar@9: replaced by corresponding components of the $m$-tuple that gives the
alpar@9: resultant $n$-tuple, which is included in the elemental set to be
alpar@9: defined. For example, if the slice $(a,*,1,2,*)$ is in effect, and
alpar@9: 2-tuple $(3,b)$ is encountered in a subsequent data record, the
alpar@9: resultant 5-tuple included in the elemental set is $(a,3,1,2,b)$.
alpar@9: 
alpar@9: The slice having no asterisks itself defines a complete $n$-tuple,
alpar@9: which is included in the elemental set.
alpar@9: 
alpar@9: Being once specified the slice effects until either a new slice or the
alpar@9: end of data block is encountered. Note that if no slice is specified in
alpar@9: the data block, one, components of which are all asterisks, is assumed.
alpar@9: 
alpar@9: \subsubsection{Simple data record}
alpar@9: 
alpar@9: The {\it simple data record} defines one $n$-tuple in a simple format
alpar@9: and has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: $t_1$ {\tt,} $t_2$ {\tt,} \dots {\tt,} $t_n$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $t_1$, $t_2$, \dots, $t_n$ are components of the
alpar@9: $n$-tuple. Each component can be a number or symbol. Commae between
alpar@9: components are optional and may be omitted.
alpar@9: 
alpar@9: \subsubsection{Matrix data record}
alpar@9: 
alpar@9: The {\it matrix data record} defines several 2-tuples (doublets) in
alpar@9: a matrix format and has the following syntactic form:
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: $$\begin{array}{cccccc}
alpar@9: \mbox{{\tt:}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
alpar@9: r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
alpar@9: r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
alpar@9: \multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
alpar@9: r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
alpar@9: \end{array}$$
alpar@9: where $r_1$, $r_2$, \dots, $r_m$ are numbers and/or symbols
alpar@9: corresponding to rows of the matrix; $c_1$, $c_2$, \dots, $c_n$ are
alpar@9: numbers and/or symbols corresponding to columns of the matrix, $a_{11}$,
alpar@9: $a_{12}$, \dots, $a_{mn}$ are matrix elements, which can be either
alpar@9: {\tt+} or {\tt-}. (In this data record the delimiter {\tt:} preceding
alpar@9: the column list and the delimiter {\tt:=} following the column list
alpar@9: cannot be omitted.)
alpar@9: 
alpar@9: Each element $a_{ij}$ of the matrix data block (where $1\leq i\leq m$,
alpar@9: $1\leq j\leq n$) corresponds to 2-tuple $(r_i,c_j)$. If $a_{ij}$ is the
alpar@9: plus sign ({\tt+}), that 2-tuple (or a longer $n$-tuple, if a slice is
alpar@9: used) is included in the elemental set. Otherwise, if $a_{ij}$ is the
alpar@9: minus sign ({\tt-}), that 2-tuple is not included in the elemental set.
alpar@9: 
alpar@9: Since the matrix data record defines 2-tuples, either the elemental set
alpar@9: must consist of 2-tuples or the slice currently used must be
alpar@9: 2-dimensional.
alpar@9: 
alpar@9: \subsubsection{Transposed matrix data record}
alpar@9: 
alpar@9: The {\it transposed matrix data record} has the following syntactic
alpar@9: form:
alpar@9: $$\begin{array}{cccccc}
alpar@9: \mbox{{\tt(tr) :}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
alpar@9: r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
alpar@9: r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
alpar@9: \multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
alpar@9: r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
alpar@9: \end{array}$$
alpar@9: (In this case the delimiter {\tt:} following the keyword {\tt(tr)} is
alpar@9: optional and may be omitted.)
alpar@9: 
alpar@9: This data record is completely analogous to the matrix data record (see
alpar@9: above) with only exception that in this case each element $a_{ij}$ of
alpar@9: the matrix corresponds to 2-tuple $(c_j,r_i)$ rather than $(r_i,c_j)$.
alpar@9: 
alpar@9: Being once specified the {\tt(tr)} indicator affects all subsequent
alpar@9: data records until either a slice or the end of data block is
alpar@9: encountered.
alpar@9: 
alpar@9: \subsection{Parameter data block}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \framebox[345pt][l]{
alpar@9: \parbox[c][80pt]{345pt}{
alpar@9: \hspace{6pt} {\tt param} {\it name} {\tt,} {\it record} {\tt,} \dots
alpar@9: {\tt,} {\it record} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt param} {\it name} {\tt default} {\it value} {\tt,}
alpar@9: {\it record} {\tt,} \dots {\tt,} {\it record} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt param} {\tt:} {\it tabbing-data} {\tt;}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \hspace{6pt} {\tt param} {\tt default} {\it value} {\tt:}
alpar@9: {\it tabbing-data} {\tt;}
alpar@9: }}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \setlength{\leftmargini}{60pt}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
alpar@9: parameter;
alpar@9: \item[\hspace*{54pt}] {\it value} is an optional default value of the
alpar@9: parameter;
alpar@9: \item[\hspace*{54pt}] {\it record}, \dots, {\it record} are data
alpar@9: records;
alpar@9: \item[\hspace*{54pt}] {\it tabbing-data} specifies parameter data in
alpar@9: the tabbing format.
alpar@9: \end{description}
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\rm Note:}\hspace*{31pt}] Commae preceding data records may be
alpar@9: omitted.
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent Data records:
alpar@9: 
alpar@9: \begin{description}
alpar@9: \item[{\tt :=}\hspace*{45pt}] is a non-significant data record, which
alpar@9: may be used freely to improve readability;
alpar@9: \item[{\tt[} {\it slice} {\tt]}\hspace*{18.5pt}] specifies a slice;
alpar@9: \item[{\it plain-data}\hspace*{11pt}] specifies parameter data in the
alpar@9: plain format;
alpar@9: \item[{\tt:} {\it tabular-data}]\hspace*{0pt}\\
alpar@9: specifies parameter data in the tabular format;
alpar@9: \item[{\tt(tr)} {\tt:} {\it tabular-data}]\hspace*{0pt}\\
alpar@9: specifies set data in the transposed tabular format. (In this case the
alpar@9: colon following the keyword {\tt(tr)} may be omitted.)
alpar@9: \end{description}
alpar@9: 
alpar@9: \noindent{\bf Examples}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: param T := 4;
alpar@9: param month := 1 'Jan' 2 'Feb' 3 'Mar' 4 'Apr' 5 'May';
alpar@9: param month := [1] Jan, [2] Feb, [3] Mar, [4] Apr, [5] May;
alpar@9: param day := [Sun] 0, [Mon] 1, [Tue] 2, [Wed] 3, [Thu] 4,
alpar@9:              [Fri] 5, [Sat] 6;
alpar@9: param init_stock := iron 7.32 nickel 35.8;
alpar@9: param init_stock [*] iron 7.32, nickel 35.8;
alpar@9: param cost [iron] .025 [nickel] .03;
alpar@9: param value := iron -.1, nickel .02;
alpar@9: param       : init_stock cost value :=
alpar@9:       iron       7.32    .025  -.1
alpar@9:       nickel    35.8     .03    .02 ;
alpar@9: param : raw : init_stock cost value :=
alpar@9:       iron       7.32    .025  -.1
alpar@9:       nickel    35.8     .03    .02 ;
alpar@9: param demand default 0 (tr)
alpar@9:        :  FRA  DET  LAN  WIN  STL  FRE  LAF :=
alpar@9:    bands  300   .   100   75   .   225  250
alpar@9:    coils  500  750  400  250   .   850  500
alpar@9:    plate  100   .    .    50  200   .   250 ;
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: param trans_cost :=
alpar@9:    [*,*,bands]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
alpar@9:          GARY     30   10    8   10   11   71    6
alpar@9:          CLEV     22    7   10    7   21   82   13
alpar@9:          PITT     19   11   12   10   25   83   15
alpar@9:    [*,*,coils]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
alpar@9:          GARY     39   14   11   14   16   82    8
alpar@9:          CLEV     27    9   12    9   26   95   17
alpar@9:          PITT     24   14   17   13   28   99   20
alpar@9:    [*,*,plate]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
alpar@9:          GARY     41   15   12   16   17   86    8
alpar@9:          CLEV     29    9   13    9   28   99   18
alpar@9:          PITT     26   14   17   13   31  104   20 ;
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: The {\it parameter data block} is used to specify complete data for a
alpar@9: parameter (or parameters, if data are specified in the tabbing format).
alpar@9: 
alpar@9: Data blocks can be specified only for non-computable parameters, i.e.
alpar@9: for parameters, which have no assign ({\tt:=}) attribute in the
alpar@9: corresponding parameter statements.
alpar@9: 
alpar@9: Data defined in the parameter data block are coded as a sequence of
alpar@9: data records described below. Additionally the data block can be
alpar@9: provided with the optional {\tt default} attribute, which specifies a
alpar@9: default numeric or symbolic value of the parameter (parameters). This
alpar@9: default value is assigned to the parameter or its members, if
alpar@9: no appropriate value is defined in the parameter data block. The
alpar@9: {\tt default} attribute cannot be used, if it is already specified in
alpar@9: the corresponding parameter statement.
alpar@9: 
alpar@9: \subsubsection{Assign data record}
alpar@9: 
alpar@9: The {\it assign} ({\tt:=}) {\it data record} is a non-signficant
alpar@9: element. It may be used for improving readability of data blocks.
alpar@9: 
alpar@9: \subsubsection{Slice data record}
alpar@9: 
alpar@9: The {\it slice data record} is a control record, which specifies a
alpar@9: {\it slice} of the parameter array. It has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: {\tt[} $s_1$ {\tt,} $s_2$ {\tt,} \dots {\tt,} $s_n$ {\tt]}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $s_1$, $s_2$, \dots, $s_n$ are components of the slice.
alpar@9: 
alpar@9: Each component of the slice can be a number or symbol or the asterisk
alpar@9: ({\tt*}). The number of components in the slice must be the same as the
alpar@9: dimension of the parameter. For instance, if the parameter is a
alpar@9: 4-dimensional array, the slice must have four components. The number of
alpar@9: asterisks in the slice is called the {\it slice dimension}.
alpar@9: 
alpar@9: The effect of using slices is the following. If a $m$-dimensional slice
alpar@9: (i.e. a slice having $m$ asterisks) is specified in the data block, all
alpar@9: subsequent data records must specify subscripts of the parameter
alpar@9: members as if the parameter were $m$-dimensional, not $n$-dimensional.
alpar@9: 
alpar@9: Whenever $m$ subscripts are encountered, each asterisk in the slice is
alpar@9: replaced by corresponding subscript that gives $n$ subscripts, which
alpar@9: define the actual parameter member. For example, if the slice
alpar@9: $[a,*,1,2,*]$ is in effect, and subscripts 3 and $b$ are encountered in
alpar@9: a subsequent data record, the complete subscript list used to choose a
alpar@9: parameter member is $[a,3,1,2,b]$.
alpar@9: 
alpar@9: It is allowed to specify a slice having no asterisks. Such slice itself
alpar@9: defines a complete subscript list, in which case the next data record
alpar@9: should define only a single value of corresponding parameter member.
alpar@9: 
alpar@9: Being once specified the slice effects until either a new slice or the
alpar@9: end of data block is encountered. Note that if no slice is specified in
alpar@9: the data block, one, components of which are all asterisks, is assumed.
alpar@9: 
alpar@9: \subsubsection{Plain data record}
alpar@9: 
alpar@9: The {\it plain data record} defines a subscript list and a single value
alpar@9: in the plain format. This record has the following syntactic form:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: $t_1$ {\tt,} $t_2$ {\tt,} \dots {\tt,} $t_n$ {\tt,} $v$
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where $t_1$, $t_2$, \dots, $t_n$ are subscripts, and $v$ is a
alpar@9: value. Each subscript as well as the value can be a number or symbol.
alpar@9: Commae following subscripts are optional and may be omitted.
alpar@9: 
alpar@9: In case of 0-dimensional parameter or slice the plain data record has
alpar@9: no subscripts and consists of a single value only.
alpar@9: 
alpar@9: \subsubsection{Tabular data record}
alpar@9: 
alpar@9: The {\it tabular data record} defines several values, where each value
alpar@9: is provided with two subscripts. This record has the following
alpar@9: syntactic form:
alpar@9: $$\begin{array}{cccccc}
alpar@9: \mbox{{\tt:}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
alpar@9: r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
alpar@9: r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
alpar@9: \multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
alpar@9: r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
alpar@9: \end{array}$$
alpar@9: where $r_1$, $r_2$, \dots, $r_m$ are numbers and/or symbols
alpar@9: corresponding to rows of the table; $c_1$, $c_2$, \dots, $c_n$ are
alpar@9: numbers and/or symbols corresponding to columns of the table, $a_{11}$,
alpar@9: $a_{12}$, \dots, $a_{mn}$ are table elements. Each element can be a
alpar@9: number or symbol or the single decimal point ({\tt.}). (In this data
alpar@9: record the delimiter {\tt:} preceding the column list and the delimiter
alpar@9: {\tt:=} following the column list cannot be omitted.)
alpar@9: 
alpar@9: Each element $a_{ij}$ of the tabular data block ($1\leq i\leq m$,
alpar@9: $1\leq j\leq n$) defines two subscripts, where the first subscript is
alpar@9: $r_i$, and the second one is $c_j$. These subscripts are used in
alpar@9: conjunction with the current slice to form the complete subscript list
alpar@9: that identifies a particular member of the parameter array. If $a_{ij}$
alpar@9: is a number or symbol, this value is assigned to the parameter member.
alpar@9: However, if $a_{ij}$ is the single decimal point, the member is
alpar@9: assigned a default value specified either in the parameter data block
alpar@9: or in the parameter statement, or, if no default value is specified,
alpar@9: the member remains undefined.
alpar@9: 
alpar@9: Since the tabular data record provides two subscripts for each value,
alpar@9: either the parameter or the slice currently used must be 2-dimensional.
alpar@9: 
alpar@9: \subsubsection{Transposed tabular data record}
alpar@9: 
alpar@9: The {\it transposed tabular data record} has the following syntactic
alpar@9: form:
alpar@9: $$\begin{array}{cccccc}
alpar@9: \mbox{{\tt(tr) :}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
alpar@9: r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
alpar@9: r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
alpar@9: \multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
alpar@9: r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
alpar@9: \end{array}$$
alpar@9: (In this case the delimiter {\tt:} following the keyword {\tt(tr)} is
alpar@9: optional and may be omitted.)
alpar@9: 
alpar@9: This data record is completely analogous to the tabular data record
alpar@9: (see above) with only exception that the first subscript defined by
alpar@9: element $a_{ij}$ is $c_j$ while the second one is $r_i$.
alpar@9: 
alpar@9: Being once specified the {\tt(tr)} indicator affects all subsequent
alpar@9: data records until either a slice or the end of data block is
alpar@9: encountered.
alpar@9: 
alpar@9: \subsubsection{Tabbing data format}
alpar@9: 
alpar@9: The parameter data block in the {\it tabbing format} has the following
alpar@9: syntactic form:
alpar@9: $$\begin{array}{p{12pt}@{\ }l@{\ }c@{\ }l@{\ }c@{\ }l@{\ }r@{\ }l@{\ }c
alpar@9: @{\ }l@{\ }c@{\ }l@{\ }l}
alpar@9: \multicolumn{7}{@{}c@{}}{\mbox{\tt param}\ \mbox{\tt default}\ \mbox
alpar@9: {\it value}\ \mbox{\tt:}\ \mbox{\it s}\ \mbox{\tt:}}&
alpar@9: p_1&\mbox{\tt,}&p_2&\mbox{\tt,} \dots \mbox{\tt,}&p_k&\mbox{\tt:=}\\
alpar@9: &t_{11}&\mbox{\tt,}&t_{12}&\mbox{\tt,} \dots \mbox{\tt,}&t_{1n}&
alpar@9: \mbox{\tt,}&a_{11}&\mbox{\tt,}&a_{12}&\mbox{\tt,} \dots \mbox{\tt,}&
alpar@9: a_{1k}\\
alpar@9: &t_{21}&\mbox{\tt,}&t_{22}&\mbox{\tt,} \dots \mbox{\tt,}&t_{2n}&
alpar@9: \mbox{\tt,}&a_{21}&\mbox{\tt,}&a_{22}&\mbox{\tt,} \dots \mbox{\tt,}&
alpar@9: a_{2k}\\
alpar@9: \multicolumn{13}{c}
alpar@9: {.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
alpar@9: &t_{m1}&\mbox{\tt,}&t_{m2}&\mbox{\tt,} \dots \mbox{\tt,}&t_{mn}&
alpar@9: \mbox{\tt,}&a_{m1}&\mbox{\tt,}&a_{m2}&\mbox{\tt,} \dots \mbox{\tt,}&
alpar@9: a_{mk}&\mbox{\tt;}\\
alpar@9: \end{array}$$
alpar@9: 
alpar@9: {\it Notes:}
alpar@9: 
alpar@9: 1. The keyword {\tt default} may be omitted along with a value
alpar@9: following it.
alpar@9: 
alpar@9: 2. Symbolic name {\tt s} may be omitted along with the colon following
alpar@9: it.
alpar@9: 
alpar@9: 3. All comae are optional and may be omitted.
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: The data block in the tabbing format shown above is exactly equivalent
alpar@9: to the following data blocks for $j=1,2,\dots,k$:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: {\tt set} {\it s} {\tt:=}
alpar@9: {\tt(}$t_{11}${\tt,}$t_{12}${\tt,}\dots{\tt,}$t_{1n}${\tt)}
alpar@9: {\tt(}$t_{21}${\tt,}$t_{22}${\tt,}\dots{\tt,}$t_{2n}${\tt)} \dots
alpar@9: {\tt(}$t_{m1}${\tt,}$t_{m2}${\tt,}\dots{\tt,}$t_{mn}${\tt)} {\tt;}
alpar@9: 
alpar@9: {\tt param} $p_j$ {\tt default} {\it value} {\tt:=}
alpar@9: 
alpar@9: $\!${\tt[}$t_{11}${\tt,}$t_{12}${\tt,}\dots{\tt,}$t_{1n}${\tt]}
alpar@9: $a_{1j}$
alpar@9: {\tt[}$t_{21}${\tt,}$t_{22}${\tt,}\dots{\tt,}$t_{2n}${\tt]} $a_{2j}$
alpar@9: \dots
alpar@9: {\tt[}$t_{m1}${\tt,}$t_{m2}${\tt,}\dots{\tt,}$t_{mn}${\tt]} $a_{mj}$
alpar@9: {\tt;}
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \appendix
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Using suffixes}
alpar@9: 
alpar@9: Suffixes can be used to retrieve additional values associated with
alpar@9: model variables, constraints, and objectives.
alpar@9: 
alpar@9: A {\it suffix} consists of a period ({\tt.}) followed by a non-reserved
alpar@9: keyword. For example, if {\tt x} is a two-dimensional variable,
alpar@9: {\tt x[i,j].lb} is a numeric value equal to the lower bound of
alpar@9: elemental variable {\tt x[i,j]}, which (value) can be used everywhere
alpar@9: in expressions like a numeric parameter.
alpar@9: 
alpar@9: For model variables suffixes have the following meaning:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt.lb}&lower bound\\
alpar@9: {\tt.ub}&upper bound\\
alpar@9: {\tt.status}&status in the solution:\\
alpar@9: &0 --- undefined\\
alpar@9: &1 --- basic\\
alpar@9: &2 --- non-basic on lower bound\\
alpar@9: &3 --- non-basic on upper bound\\
alpar@9: &4 --- non-basic free (unbounded) variable\\
alpar@9: &5 --- non-basic fixed variable\\
alpar@9: {\tt.val}&primal value in the solution\\
alpar@9: {\tt.dual}&dual value (reduced cost) in the solution\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: For model constraints and objectives suffixes have the following
alpar@9: meaning:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{96pt}p{222pt}@{}}
alpar@9: {\tt.lb}&lower bound of the linear form\\
alpar@9: {\tt.ub}&upper bound of the linear form\\
alpar@9: {\tt.status}&status in the solution:\\
alpar@9: &0 --- undefined\\
alpar@9: &1 --- non-active\\
alpar@9: &2 --- active on lower bound\\
alpar@9: &3 --- active on upper bound\\
alpar@9: &4 --- active free (unbounded) row\\
alpar@9: &5 --- active equality constraint\\
alpar@9: {\tt.val}&primal value of the linear form in the solution\\
alpar@9: {\tt.dual}&dual value (reduced cost) of the linear form in the
alpar@9: solution\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Note that suffixes {\tt.status}, {\tt.val}, and {\tt.dual} can be used
alpar@9: only below the solve statement.
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Date and time functions}
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: by Andrew Makhorin \verb|<mao@gnu.org>|
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: and Heinrich Schuchardt \verb|<heinrich.schuchardt@gmx.de>|
alpar@9: 
alpar@9: \subsection{Obtaining current calendar time}
alpar@9: \label{gmtime}
alpar@9: 
alpar@9: To obtain the current calendar time in MathProg there exists the
alpar@9: function {\tt gmtime}. It has no arguments and returns the number of
alpar@9: seconds elapsed since 00:00:00 on January 1, 1970, Coordinated
alpar@9: Universal Time (UTC). For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   param utc := gmtime();|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: MathProg has no function to convert UTC time returned by the function
alpar@9: {\tt gmtime} to {\it local} calendar times. Thus, if you need to
alpar@9: determine the current local calendar time, you have to add to the UTC
alpar@9: time returned the time offset from UTC expressed in seconds. For
alpar@9: example, the time in Berlin during the winter is one hour ahead of UTC
alpar@9: that corresponds to the time offset +1 hour = +3600 secs, so the
alpar@9: current winter calendar time in Berlin may be determined as follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   param now := gmtime() + 3600;|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent Similarly, the summer time in Chicago (Central Daylight Time)
alpar@9: is five hours behind UTC, so the corresponding current local calendar
alpar@9: time may be determined as follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   param now := gmtime() - 5 * 3600;|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Note that the value returned by {\tt gmtime} is volatile, i.e. being
alpar@9: called several times this function may return different values.
alpar@9: 
alpar@9: \subsection{Converting character string to calendar time}
alpar@9: \label{str2time}
alpar@9: 
alpar@9: The function {\tt str2time(}{\it s}{\tt,} {\it f}{\tt)} converts a
alpar@9: character string (timestamp) specified by its first argument {\it s},
alpar@9: which must be a symbolic expression, to the calendar time suitable for
alpar@9: arithmetic calculations. The conversion is controlled by the specified
alpar@9: format string {\it f} (the second argument), which also must be a
alpar@9: symbolic expression.
alpar@9: 
alpar@9: The result of conversion returned by {\tt str2time} has the same
alpar@9: meaning as values returned by the function {\tt gmtime} (see Subsection
alpar@9: \ref{gmtime}, page \pageref{gmtime}). Note that {\tt str2time} does
alpar@9: {\tt not} correct the calendar time returned for the local timezone,
alpar@9: i.e. being applied to 00:00:00 on January 1, 1970 it always returns 0.
alpar@9: 
alpar@9: For example, the model statements:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   param s, symbolic, := "07/14/98 13:47";|
alpar@9: 
alpar@9: \verb|   param t := str2time(s, "%m/%d/%y %H:%M");|
alpar@9: 
alpar@9: \verb|   display t;|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent produce the following printout:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   t = 900424020|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent where the calendar time printed corresponds to 13:47:00 on
alpar@9: July 14, 1998.
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: The format string passed to the function {\tt str2time} consists of
alpar@9: conversion specifiers and ordinary characters. Each conversion
alpar@9: specifier begins with a percent ({\tt\%}) character followed by a
alpar@9: letter.
alpar@9: 
alpar@9: The following conversion specifiers may be used in the format string:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%b}&The abbreviated month name (case insensitive). At least three
alpar@9: first letters of the month name must appear in the input string.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%d}&The day of the month as a decimal number (range 1 to 31).
alpar@9: Leading zero is permitted, but not required.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%h}&The same as {\tt\%b}.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%H}&The hour as a decimal number, using a 24-hour clock (range 0
alpar@9: to 23). Leading zero is permitted, but not required.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%m}&The month as a decimal number (range 1 to 12). Leading zero is
alpar@9: permitted, but not required.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%M}&The minute as a decimal number (range 0 to 59). Leading zero
alpar@9: is permitted, but not required.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%S}&The second as a decimal number (range 0 to 60). Leading zero
alpar@9: is permitted, but not required.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%y}&The year without a century as a decimal number (range 0 to 99).
alpar@9: Leading zero is permitted, but not required. Input values in the range
alpar@9: 0 to 68 are considered as the years 2000 to 2068 while the values 69 to
alpar@9: 99 as the years 1969 to 1999.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%z}&The offset from GMT in ISO 8601 format.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%\%}&A literal {\tt\%} character.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: All other (ordinary) characters in the format string must have a
alpar@9: matching character in the input string to be converted. Exceptions are
alpar@9: spaces in the input string which can match zero or more space
alpar@9: characters in the format string.
alpar@9: 
alpar@9: If some date and/or time component(s) are missing in the format and,
alpar@9: therefore, in the input string, the function {\tt str2time} uses their
alpar@9: default values corresponding to 00:00:00 on January 1, 1970, that is,
alpar@9: the default value of the year is 1970, the default value of the month
alpar@9: is January, etc.
alpar@9: 
alpar@9: The function {\tt str2time} is applicable to all calendar times in the
alpar@9: range 00:00:00 on January 1, 0001 to 23:59:59 on December 31, 4000 of
alpar@9: the Gregorian calendar.
alpar@9: 
alpar@9: \subsection{Converting calendar time to character string}
alpar@9: \label{time2str}
alpar@9: 
alpar@9: The function {\tt time2str(}{\it t}{\tt,} {\it f}{\tt)} converts the
alpar@9: calendar time specified by its first argument {\it t}, which must be a
alpar@9: numeric expression, to a character string (symbolic value). The
alpar@9: conversion is controlled by the specified format string {\it f} (the
alpar@9: second argument), which must be a symbolic expression.
alpar@9: 
alpar@9: The calendar time passed to {\tt time2str} has the same meaning as
alpar@9: values returned by the function {\tt gmtime} (see Subsection
alpar@9: \ref{gmtime}, page \pageref{gmtime}). Note that {\tt time2str} does
alpar@9: {\it not} correct the specified calendar time for the local timezone,
alpar@9: i.e. the calendar time 0 always corresponds to 00:00:00 on January 1,
alpar@9: 1970.
alpar@9: 
alpar@9: For example, the model statements:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   param s, symbolic, := time2str(gmtime(), "%FT%TZ");|
alpar@9: 
alpar@9: \verb|   display s;|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent may produce the following printout:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   s = '2008-12-04T00:23:45Z'|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent which is a timestamp in the ISO format.
alpar@9: 
alpar@9: The format string passed to the function {\tt time2str} consists of
alpar@9: conversion specifiers and ordinary characters. Each conversion
alpar@9: specifier begins with a percent ({\tt\%}) character followed by a
alpar@9: letter.
alpar@9: 
alpar@9: The following conversion specifiers may be used in the format string:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%a}&The abbreviated (2-character) weekday name.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%A}&The full weekday name.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%b}&The abbreviated (3-character) month name.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%B}&The full month name.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%C}&The century of the year, that is the greatest integer not
alpar@9: greater than the year divided by 100.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%d}&The day of the month as a decimal number (range 01 to 31).\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%D}&The date using the format \verb|%m/%d/%y|.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%e}&The day of the month like with \verb|%d|, but padded with
alpar@9: blank rather than zero.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%F}&The date using the format \verb|%Y-%m-%d|.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%g}&The year corresponding to the ISO week number, but without the
alpar@9: century (range 00 to 99). This has the same format and value as
alpar@9: \verb|%y|, except that if the ISO week number (see \verb|%V|) belongs
alpar@9: to the previous or next year, that year is used instead.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%G}&The year corresponding to the ISO week number. This has the
alpar@9: same format and value as \verb|%Y|, except that if the ISO week number
alpar@9: (see \verb|%V|) belongs to the previous or next year, that year is used
alpar@9: instead.
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%h}&The same as \verb|%b|.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%H}&The hour as a decimal number, using a 24-hour clock (range 00
alpar@9: to 23).\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%I}&The hour as a decimal number, using a 12-hour clock (range 01
alpar@9: to 12).\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%j}&The day of the year as a decimal number (range 001 to 366).\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%k}&The hour as a decimal number, using a 24-hour clock like
alpar@9: \verb|%H|, but padded with blank rather than zero.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%l}&The hour as a decimal number, using a 12-hour clock like
alpar@9: \verb|%I|, but padded with blank rather than zero.
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%m}&The month as a decimal number (range 01 to 12).\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%M}&The minute as a decimal number (range 00 to 59).\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%p}&Either {\tt AM} or {\tt PM}, according to the given time value.
alpar@9: Midnight is treated as {\tt AM} and noon as {\tt PM}.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%P}&Either {\tt am} or {\tt pm}, according to the given time value.
alpar@9: Midnight is treated as {\tt am} and noon as {\tt pm}.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%R}&The hour and minute in decimal numbers using the format
alpar@9: \verb|%H:%M|.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%S}&The second as a decimal number (range 00 to 59).\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%T}&The time of day in decimal numbers using the format
alpar@9: \verb|%H:%M:%S|.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%u}&The day of the week as a decimal number (range 1 to 7), Monday
alpar@9: being 1.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%U}&The week number of the current year as a decimal number (range
alpar@9: 00 to 53), starting with the first Sunday as the first day of the first
alpar@9: week. Days preceding the first Sunday in the year are considered to be
alpar@9: in week 00.
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%V}&The ISO week number as a decimal number (range 01 to 53). ISO
alpar@9: weeks start with Monday and end with Sunday. Week 01 of a year is the
alpar@9: first week which has the majority of its days in that year; this is
alpar@9: equivalent to the week containing January 4. Week 01 of a year can
alpar@9: contain days from the previous year. The week before week 01 of a year
alpar@9: is the last week (52 or 53) of the previous year even if it contains
alpar@9: days from the new year. In other word, if 1 January is Monday, Tuesday,
alpar@9: Wednesday or Thursday, it is in week 01; if 1 January is Friday,
alpar@9: Saturday or Sunday, it is in week 52 or 53 of the previous year.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%w}&The day of the week as a decimal number (range 0 to 6), Sunday
alpar@9: being 0.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%W}&The week number of the current year as a decimal number (range
alpar@9: 00 to 53), starting with the first Monday as the first day of the first
alpar@9: week. Days preceding the first Monday in the year are considered to be
alpar@9: in week 00.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%y}&The year without a century as a decimal number (range 00 to
alpar@9: 99), that is the year modulo 100.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%Y}&The year as a decimal number, using the Gregorian calendar.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \begin{tabular}{@{}p{20pt}p{298pt}@{}}
alpar@9: {\tt\%\%}&A literal \verb|%| character.\\
alpar@9: \end{tabular}
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: All other (ordinary) characters in the format string are simply copied
alpar@9: to the resultant string.
alpar@9: 
alpar@9: The first argument (calendar time) passed to the function {\tt time2str}
alpar@9: must be in the range from $-62135596800$ to $+64092211199$ that
alpar@9: corresponds to the period from 00:00:00 on January 1, 0001 to 23:59:59
alpar@9: on December 31, 4000 of the Gregorian calendar.
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Table drivers}
alpar@9: \label{drivers}
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: by Andrew Makhorin \verb|<mao@gnu.org>|
alpar@9: 
alpar@9: \noindent\hfil
alpar@9: and Heinrich Schuchardt \verb|<heinrich.schuchardt@gmx.de>|
alpar@9: 
alpar@9: \bigskip\bigskip
alpar@9: 
alpar@9: The {\it table driver} is a program module which provides transmitting
alpar@9: data between MathProg model objects and data tables.
alpar@9: 
alpar@9: Currently the GLPK package has four table drivers:
alpar@9: 
alpar@9: \setlength{\leftmargini}{2.5em}
alpar@9: 
alpar@9: \begin{itemize}
alpar@9: \item built-in CSV table driver;
alpar@9: \item built-in xBASE table driver;
alpar@9: \item ODBC table driver;
alpar@9: \item MySQL table driver.
alpar@9: \end{itemize}
alpar@9: 
alpar@9: \subsection{CSV table driver}
alpar@9: 
alpar@9: The CSV table driver assumes that the data table is represented in the
alpar@9: form of a plain text file in the CSV (comma-separated values) file
alpar@9: format as described below.
alpar@9: 
alpar@9: To choose the CSV table driver its name in the table statement should
alpar@9: be specified as \verb|"CSV"|, and the only argument should specify the
alpar@9: name of a plain text file containing the table. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   table data IN "CSV" "data.csv": ... ;|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: The filename suffix may be arbitrary, however, it is recommended to use
alpar@9: the suffix `\verb|.csv|'.
alpar@9: 
alpar@9: On reading input tables the CSV table driver provides an implicit field
alpar@9: named \verb|RECNO|, which contains the current record number. This
alpar@9: field can be specified in the input table statement as if there were
alpar@9: the actual field having the name \verb|RECNO| in the CSV file. For
alpar@9: example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   table list IN "CSV" "list.csv": num <- [RECNO], ... ;|
alpar@9: 
alpar@9: \subsubsection*{CSV format\footnote{This material is based on the RFC
alpar@9: document 4180.}}
alpar@9: 
alpar@9: The CSV (comma-separated values) format is a plain text file format
alpar@9: defined as follows.
alpar@9: 
alpar@9: 1. Each record is located on a separate line, delimited by a line
alpar@9: break. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   aaa,bbb,ccc\n|
alpar@9: 
alpar@9: \verb|   xxx,yyy,zzz\n|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent
alpar@9: where \verb|\n| means the control character \verb|LF| ({\tt 0x0A}).
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: 2. The last record in the file may or may not have an ending line
alpar@9: break. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   aaa,bbb,ccc\n|
alpar@9: 
alpar@9: \verb|   xxx,yyy,zzz|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: 3. There should be a header line appearing as the first line of the
alpar@9: file in the same format as normal record lines. This header should
alpar@9: contain names corresponding to the fields in the file. The number of
alpar@9: field names in the header line should be the same as the number of
alpar@9: fields in the records of the file. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   name1,name2,name3\n|
alpar@9: 
alpar@9: \verb|   aaa,bbb,ccc\n|
alpar@9: 
alpar@9: \verb|   xxx,yyy,zzz\n|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: 4. Within the header and each record there may be one or more fields
alpar@9: separated by commas. Each line should contain the same number of fields
alpar@9: throughout the file. Spaces are considered as part of a field and
alpar@9: therefore not ignored. The last field in the record should not be
alpar@9: followed by a comma. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   aaa,bbb,ccc\n|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: 5. Fields may or may not be enclosed in double quotes. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   "aaa","bbb","ccc"\n|
alpar@9: 
alpar@9: \verb|   zzz,yyy,xxx\n|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: 6. If a field is enclosed in double quotes, each double quote which is
alpar@9: part of the field should be coded twice. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   "aaa","b""bb","ccc"\n|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent{\bf Example}
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: FROM,TO,DISTANCE,COST
alpar@9: Seattle,New-York,2.5,0.12
alpar@9: Seattle,Chicago,1.7,0.08
alpar@9: Seattle,Topeka,1.8,0.09
alpar@9: San-Diego,New-York,2.5,0.15
alpar@9: San-Diego,Chicago,1.8,0.10
alpar@9: San-Diego,Topeka,1.4,0.07
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \subsection{xBASE table driver}
alpar@9: 
alpar@9: The xBASE table driver assumes that the data table is stored in the
alpar@9: .dbf file format.
alpar@9: 
alpar@9: To choose the xBASE table driver its name in the table statement should
alpar@9: be specified as \verb|"xBASE"|, and the first argument should specify
alpar@9: the name of a .dbf file containing the table. For the output table there
alpar@9: should be the second argument defining the table format in the form
alpar@9: \verb|"FF...F"|, where \verb|F| is either {\tt C({\it n})},
alpar@9: which specifies a character field of length $n$, or
alpar@9: {\tt N({\it n}{\rm [},{\it p}{\rm ]})}, which specifies a numeric field
alpar@9: of length $n$ and precision $p$ (by default $p$ is 0).
alpar@9: 
alpar@9: The following is a simple example which illustrates creating and
alpar@9: reading a .dbf file:
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: table tab1{i in 1..10} OUT "xBASE" "foo.dbf"
alpar@9:    "N(5)N(10,4)C(1)C(10)": 2*i+1 ~ B, Uniform(-20,+20) ~ A,
alpar@9:    "?" ~ FOO, "[" & i & "]" ~ C;
alpar@9: set S, dimen 4;
alpar@9: table tab2 IN "xBASE" "foo.dbf": S <- [B, C, RECNO, A];
alpar@9: display S;
alpar@9: end;
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \subsection{ODBC table driver}
alpar@9: 
alpar@9: The ODBC table driver allows connecting to SQL databases using an
alpar@9: implementation of the ODBC interface based on the Call Level Interface
alpar@9: (CLI).\footnote{The corresponding software standard is defined in
alpar@9: ISO/IEC 9075-3:2003.}
alpar@9: 
alpar@9: \paragraph{Debian GNU/Linux.}
alpar@9: Under Debian GNU/Linux the ODBC table driver uses the iODBC
alpar@9: package,\footnote{See {\tt<http://www.iodbc.org/>}.} which should be
alpar@9: installed before building the GLPK package. The installation can be
alpar@9: effected with the following command:
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: sudo apt-get install libiodbc2-dev
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: Note that on configuring the GLPK package to enable using the iODBC
alpar@9: library the option `\verb|--enable-odbc|' should be passed to the
alpar@9: configure script.
alpar@9: 
alpar@9: The individual databases must be entered for systemwide usage in
alpar@9: \linebreak \verb|/etc/odbc.ini| and \verb|/etc/odbcinst.ini|. Database
alpar@9: connections to be used by a single user are specified by files in the
alpar@9: home directory (\verb|.odbc.ini| and \verb|.odbcinst.ini|).
alpar@9: 
alpar@9: \paragraph{Microsoft Windows.}
alpar@9: Under Microsoft Windows the ODBC table driver uses the Microsoft ODBC
alpar@9: library. To enable this feature the symbol:
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: #define ODBC_DLNAME "odbc32.dll"
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \noindent
alpar@9: should be defined in the GLPK configuration file `\verb|config.h|'.
alpar@9: 
alpar@9: Data sources can be created via the Administrative Tools from the
alpar@9: Control Panel.
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: To choose the ODBC table driver its name in the table statement should
alpar@9: be specified as \verb|'ODBC'| or \verb|'iODBC'|.
alpar@9: 
alpar@9: The argument list is specified as follows.
alpar@9: 
alpar@9: The first argument is the connection string passed to the ODBC library,
alpar@9: for example:
alpar@9: 
alpar@9: \verb|'DSN=glpk;UID=user;PWD=password'|, or
alpar@9: 
alpar@9: \verb|'DRIVER=MySQL;DATABASE=glpkdb;UID=user;PWD=password'|.
alpar@9: 
alpar@9: Different parts of the string are separated by semicolons. Each part
alpar@9: consists of a pair {\it fieldname} and {\it value} separated by the
alpar@9: equal sign. Allowable fieldnames depend on the ODBC library. Typically
alpar@9: the following fieldnames are allowed:
alpar@9: 
alpar@9: \verb|DATABASE | database;
alpar@9: 
alpar@9: \verb|DRIVER   | ODBC driver;
alpar@9: 
alpar@9: \verb|DSN      | name of a data source;
alpar@9: 
alpar@9: \verb|FILEDSN  | name of a file data source;
alpar@9: 
alpar@9: \verb|PWD      | user password;
alpar@9: 
alpar@9: \verb|SERVER   | database;
alpar@9: 
alpar@9: \verb|UID      | user name.
alpar@9: 
alpar@9: The second argument and all following are considered to be SQL
alpar@9: statements
alpar@9: 
alpar@9: SQL statements may be spread over multiple arguments.  If the last
alpar@9: character of an argument is a semicolon this indicates the end of
alpar@9: a SQL statement.
alpar@9: 
alpar@9: The arguments of a SQL statement are concatenated separated by space.
alpar@9: The eventual trailing semicolon will be removed.
alpar@9: 
alpar@9: All but the last SQL statement will be executed directly.
alpar@9: 
alpar@9: For IN-table the last SQL statement can be a SELECT command starting
alpar@9: with the capitalized letters \verb|'SELECT '|. If the string does not
alpar@9: start with \verb|'SELECT '| it is considered to be a table name and a
alpar@9: SELECT statement is automatically generated.
alpar@9: 
alpar@9: For OUT-table the last SQL statement can contain one or multiple
alpar@9: question marks. If it contains a question mark it is considered a
alpar@9: template for the write routine. Otherwise the string is considered a
alpar@9: table name and an INSERT template is automatically generated.
alpar@9: 
alpar@9: The writing routine uses the template with the question marks and
alpar@9: replaces the first question mark by the first output parameter, the
alpar@9: second question mark by the second output parameter and so forth. Then
alpar@9: the SQL command is issued.
alpar@9: 
alpar@9: The following is an example of the output table statement:
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: table ta { l in LOCATIONS } OUT
alpar@9:    'ODBC'
alpar@9:    'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
alpar@9:    'DROP TABLE IF EXISTS result;'
alpar@9:    'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
alpar@9:    'INSERT INTO result 'VALUES ( 4, ?, ? )' :
alpar@9:    l ~ LOC, quantity[l] ~ QUAN;
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: \noindent
alpar@9: Alternatively it could be written as follows:
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: table ta { l in LOCATIONS } OUT
alpar@9:    'ODBC'
alpar@9:    'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
alpar@9:    'DROP TABLE IF EXISTS result;'
alpar@9:    'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
alpar@9:    'result' :
alpar@9:    l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: Using templates with `\verb|?|' supports not only INSERT, but also
alpar@9: UPDATE, DELETE, etc. For example:
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: table ta { l in LOCATIONS } OUT
alpar@9:    'ODBC'
alpar@9:    'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
alpar@9:    'UPDATE result SET DATE = ' & date & ' WHERE ID = 4;'
alpar@9:    'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :
alpar@9:    quantity[l], l;
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: \subsection{MySQL table driver}
alpar@9: 
alpar@9: The MySQL table driver allows connecting to MySQL databases.
alpar@9: 
alpar@9: \paragraph{Debian GNU/Linux.}
alpar@9: Under Debian GNU/Linux the MySQL table\linebreak driver uses the MySQL
alpar@9: package,\footnote{For download development files see
alpar@9: {\tt<http://dev.mysql.com/downloads/mysql/>}.} which should be installed
alpar@9: before building the GLPK package. The installation can be effected with
alpar@9: the following command:
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: sudo apt-get install libmysqlclient15-dev
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: Note that on configuring the GLPK package to enable using the MySQL
alpar@9: library the option `\verb|--enable-mysql|' should be passed to the
alpar@9: configure script.
alpar@9: 
alpar@9: \paragraph{Microsoft Windows.}
alpar@9: Under Microsoft Windows the MySQL table driver also uses the MySQL
alpar@9: library. To enable this feature the symbol:
alpar@9: 
alpar@9: \begin{verbatim}
alpar@9: #define MYSQL_DLNAME "libmysql.dll"
alpar@9: \end{verbatim}
alpar@9: 
alpar@9: \noindent
alpar@9: should be defined in the GLPK configuration file `\verb|config.h|'.
alpar@9: 
alpar@9: \bigskip
alpar@9: 
alpar@9: To choose the MySQL table driver its name in the table statement should
alpar@9: be specified as \verb|'MySQL'|.
alpar@9: 
alpar@9: The argument list is specified as follows.
alpar@9: 
alpar@9: The first argument specifies how to connect the data base in the DSN
alpar@9: style, for example:
alpar@9: 
alpar@9: \verb|'Database=glpk;UID=glpk;PWD=gnu'|.
alpar@9: 
alpar@9: Different parts of the string are separated by semicolons. Each part
alpar@9: consists of a pair {\it fieldname} and {\it value} separated by the
alpar@9: equal sign. The following fieldnames are allowed:
alpar@9: 
alpar@9: \verb|Server   | server running the database (defaulting to localhost);
alpar@9: 
alpar@9: \verb|Database | name of the database;
alpar@9: 
alpar@9: \verb|UID      | user name;
alpar@9: 
alpar@9: \verb|PWD      | user password;
alpar@9: 
alpar@9: \verb|Port     | port used by the server (defaulting to 3306).
alpar@9: 
alpar@9: The second argument and all following are considered to be SQL
alpar@9: statements
alpar@9: 
alpar@9: SQL statements may be spread over multiple arguments.  If the last
alpar@9: character of an argument is a semicolon this indicates the end of
alpar@9: a SQL statement.
alpar@9: 
alpar@9: The arguments of a SQL statement are concatenated separated by space.
alpar@9: The eventual trailing semicolon will be removed.
alpar@9: 
alpar@9: All but the last SQL statement will be executed directly.
alpar@9: 
alpar@9: For IN-table the last SQL statement can be a SELECT command starting
alpar@9: with the capitalized letters \verb|'SELECT '|. If the string does not
alpar@9: start with \verb|'SELECT '| it is considered to be a table name and a
alpar@9: SELECT statement is automatically generated.
alpar@9: 
alpar@9: For OUT-table the last SQL statement can contain one or multiple
alpar@9: question marks. If it contains a question mark it is considered a
alpar@9: template for the write routine. Otherwise the string is considered a
alpar@9: table name and an INSERT template is automatically generated.
alpar@9: 
alpar@9: The writing routine uses the template with the question marks and
alpar@9: replaces the first question mark by the first output parameter, the
alpar@9: second question mark by the second output parameter and so forth. Then
alpar@9: the SQL command is issued.
alpar@9: 
alpar@9: The following is an example of the output table statement:
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: table ta { l in LOCATIONS } OUT
alpar@9:    'MySQL'
alpar@9:    'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
alpar@9:    'DROP TABLE IF EXISTS result;'
alpar@9:    'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
alpar@9:    'INSERT INTO result VALUES ( 4, ?, ? )' :
alpar@9:    l ~ LOC, quantity[l] ~ QUAN;
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: \noindent
alpar@9: Alternatively it could be written as follows:
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: table ta { l in LOCATIONS } OUT
alpar@9:    'MySQL'
alpar@9:    'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
alpar@9:    'DROP TABLE IF EXISTS result;'
alpar@9:    'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
alpar@9:    'result' :
alpar@9:    l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: Using templates with `\verb|?|' supports not only INSERT, but also
alpar@9: UPDATE, DELETE, etc. For example:
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: table ta { l in LOCATIONS } OUT
alpar@9:    'MySQL'
alpar@9:    'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
alpar@9:    'UPDATE result SET DATE = ' & date & ' WHERE ID = 4;'
alpar@9:    'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :
alpar@9:    quantity[l], l;
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Solving models with glpsol}
alpar@9: 
alpar@9: The GLPK package\footnote{{\tt http://www.gnu.org/software/glpk/}}
alpar@9: includes the program {\tt glpsol}, which is a stand-alone LP/MIP solver.
alpar@9: This program can be launched from the command line or from the shell to
alpar@9: solve models written in the GNU MathProg modeling language.
alpar@9: 
alpar@9: In order to tell the solver that the input file contains a model
alpar@9: description, you need to specify the option \verb|--model| in the
alpar@9: command line. For example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   glpsol --model foo.mod|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: Sometimes it is necessary to use the data section placed in a separate
alpar@9: file, in which case you may use the following command:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   glpsol --model foo.mod --data foo.dat|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent Note that if the model file also contains the data section,
alpar@9: that section is ignored.
alpar@9: 
alpar@9: If the model description contains some display and/or printf statements,
alpar@9: by default the output is sent to the terminal. In order to redirect the
alpar@9: output to a file you may use the following command:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   glpsol --model foo.mod --display foo.out|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: If you need to look at the problem, which has been generated by the
alpar@9: model translator, you may use the option \verb|--wlp| as follows:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   glpsol --model foo.mod --wlp foo.lp|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent in which case the problem data is written to file
alpar@9: \verb|foo.lp| in CPLEX LP format suitable for visual analysis.
alpar@9: 
alpar@9: Sometimes it is needed merely to check the model description not
alpar@9: solving the generated problem instance. In this case you may specify
alpar@9: the option \verb|--check|, for example:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   glpsol --check --model foo.mod --wlp foo.lp|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: In order to write a numeric solution obtained by the solver you may use
alpar@9: the following command:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \verb|   glpsol --model foo.mod --output foo.sol|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent in which case the solution is written to file \verb|foo.sol|
alpar@9: in a plain text format.
alpar@9: 
alpar@9: The complete list of the \verb|glpsol| options can be found in the
alpar@9: reference manual included in the GLPK distribution.
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \section{Example model description}
alpar@9: 
alpar@9: \subsection{Model description written in MathProg}
alpar@9: 
alpar@9: Below here is a complete example of the model description written in
alpar@9: the GNU MathProg modeling language.
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: # A TRANSPORTATION PROBLEM
alpar@9: #
alpar@9: # This problem finds a least cost shipping schedule that meets
alpar@9: # requirements at markets and supplies at factories.
alpar@9: #
alpar@9: #  References:
alpar@9: #              Dantzig G B, "Linear Programming and Extensions."
alpar@9: #              Princeton University Press, Princeton, New Jersey, 1963,
alpar@9: #              Chapter 3-3.
alpar@9: 
alpar@9: set I;
alpar@9: /* canning plants */
alpar@9: 
alpar@9: set J;
alpar@9: /* markets */
alpar@9: 
alpar@9: param a{i in I};
alpar@9: /* capacity of plant i in cases */
alpar@9: 
alpar@9: param b{j in J};
alpar@9: /* demand at market j in cases */
alpar@9: 
alpar@9: param d{i in I, j in J};
alpar@9: /* distance in thousands of miles */
alpar@9: 
alpar@9: param f;
alpar@9: /* freight in dollars per case per thousand miles */
alpar@9: 
alpar@9: param c{i in I, j in J} := f * d[i,j] / 1000;
alpar@9: /* transport cost in thousands of dollars per case */
alpar@9: 
alpar@9: var x{i in I, j in J} >= 0;
alpar@9: /* shipment quantities in cases */
alpar@9: 
alpar@9: minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
alpar@9: /* total transportation costs in thousands of dollars */
alpar@9: 
alpar@9: s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
alpar@9: /* observe supply limit at plant i */
alpar@9: 
alpar@9: s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
alpar@9: /* satisfy demand at market j */
alpar@9: 
alpar@9: data;
alpar@9: 
alpar@9: set I := Seattle San-Diego;
alpar@9: 
alpar@9: set J := New-York Chicago Topeka;
alpar@9: 
alpar@9: param a := Seattle     350
alpar@9:            San-Diego   600;
alpar@9: 
alpar@9: param b := New-York    325
alpar@9:            Chicago     300
alpar@9:            Topeka      275;
alpar@9: 
alpar@9: param d :              New-York   Chicago   Topeka :=
alpar@9:            Seattle     2.5        1.7       1.8
alpar@9:            San-Diego   2.5        1.8       1.4  ;
alpar@9: 
alpar@9: param f := 90;
alpar@9: 
alpar@9: end;
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: \subsection{Generated LP problem instance}
alpar@9: 
alpar@9: Below here is the result of the translation of the example model
alpar@9: produced by the solver \verb|glpsol| and written in CPLEX LP format
alpar@9: with the option \verb|--wlp|.
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: \* Problem: transp *\
alpar@9: 
alpar@9: Minimize
alpar@9:  cost: + 0.225 x(Seattle,New~York) + 0.153 x(Seattle,Chicago)
alpar@9:  + 0.162 x(Seattle,Topeka) + 0.225 x(San~Diego,New~York)
alpar@9:  + 0.162 x(San~Diego,Chicago) + 0.126 x(San~Diego,Topeka)
alpar@9: 
alpar@9: Subject To
alpar@9:  supply(Seattle): + x(Seattle,New~York) + x(Seattle,Chicago)
alpar@9:  + x(Seattle,Topeka) <= 350
alpar@9:  supply(San~Diego): + x(San~Diego,New~York) + x(San~Diego,Chicago)
alpar@9:  + x(San~Diego,Topeka) <= 600
alpar@9:  demand(New~York): + x(Seattle,New~York) + x(San~Diego,New~York) >= 325
alpar@9:  demand(Chicago): + x(Seattle,Chicago) + x(San~Diego,Chicago) >= 300
alpar@9:  demand(Topeka): + x(Seattle,Topeka) + x(San~Diego,Topeka) >= 275
alpar@9: 
alpar@9: End
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: \subsection{Optimal LP solution}
alpar@9: 
alpar@9: Below here is the optimal solution of the generated LP problem instance
alpar@9: found by the solver \verb|glpsol| and written in plain text format
alpar@9: with the option \verb|--output|.
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \begin{small}
alpar@9: \begin{verbatim}
alpar@9: Problem:    transp
alpar@9: Rows:       6
alpar@9: Columns:    6
alpar@9: Non-zeros:  18
alpar@9: Status:     OPTIMAL
alpar@9: Objective:  cost = 153.675 (MINimum)
alpar@9: 
alpar@9: No.   Row name   St   Activity    Lower bound  Upper bound   Marginal
alpar@9: --- ------------ -- ------------ ------------ ------------ ------------
alpar@9:   1 cost         B       153.675
alpar@9:   2 supply[Seattle]
alpar@9:                  B           300                       350
alpar@9:   3 supply[San-Diego]
alpar@9:                  NU          600                       600        < eps
alpar@9:   4 demand[New-York]
alpar@9:                  NL          325          325                     0.225
alpar@9:   5 demand[Chicago]
alpar@9:                  NL          300          300                     0.153
alpar@9:   6 demand[Topeka]
alpar@9:                  NL          275          275                     0.126
alpar@9: 
alpar@9: No. Column name  St   Activity    Lower bound  Upper bound   Marginal
alpar@9: --- ------------ -- ------------ ------------ ------------ ------------
alpar@9:   1 x[Seattle,New-York]
alpar@9:                  B             0            0
alpar@9:   2 x[Seattle,Chicago]
alpar@9:                  B           300            0
alpar@9:   3 x[Seattle,Topeka]
alpar@9:                  NL            0            0                     0.036
alpar@9:   4 x[San-Diego,New-York]
alpar@9:                  B           325            0
alpar@9:   5 x[San-Diego,Chicago]
alpar@9:                  NL            0            0                     0.009
alpar@9:   6 x[San-Diego,Topeka]
alpar@9:                  B           275            0
alpar@9: 
alpar@9: End of output
alpar@9: \end{verbatim}
alpar@9: \end{small}
alpar@9: 
alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpar@9: 
alpar@9: \newpage
alpar@9: 
alpar@9: \setcounter{secnumdepth}{-1}
alpar@9: 
alpar@9: \section{Acknowledgment}
alpar@9: 
alpar@9: The authors would like to thank the following people, who kindly read,
alpar@9: commented, and corrected the draft of this document:
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent Juan Carlos Borras \verb|<borras@cs.helsinki.fi>|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent Harley Mackenzie \verb|<hjm@bigpond.com>|
alpar@9: 
alpar@9: \medskip
alpar@9: 
alpar@9: \noindent Robbie Morrison \verb|<robbie@actrix.co.nz>|
alpar@9: 
alpar@9: \end{document}




