doc/glpk09.tex
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 06 Dec 2010 13:09:21 +0100
changeset 1 c445c931472f
permissions -rw-r--r--
Import glpk-4.45

- Generated files and doc/notes are removed
alpar@1
     1
%* glpk09.tex *%
alpar@1
     2
alpar@1
     3
\chapter{CPLEX LP Format}
alpar@1
     4
\label{chacplex}
alpar@1
     5
alpar@1
     6
\section{Prelude}
alpar@1
     7
alpar@1
     8
The CPLEX LP format\footnote{The CPLEX LP format was developed in
alpar@1
     9
the end of 1980's by CPLEX Optimization, Inc. as an input format for
alpar@1
    10
the CPLEX linear programming system. Although the CPLEX LP format is
alpar@1
    11
not as widely used as the MPS format, being row-oriented it is more
alpar@1
    12
convenient for coding mathematical programming models by human. This
alpar@1
    13
appendix describes only the features of the CPLEX LP format which are
alpar@1
    14
implemented in the GLPK package.} is intended for coding LP/MIP problem
alpar@1
    15
data. It is a row-oriented format that assumes the formulation of LP/MIP
alpar@1
    16
problem (1.1)---(1.3) (see Section \ref{seclp}, page \pageref{seclp}).
alpar@1
    17
alpar@1
    18
CPLEX LP file is a plain text file written in CPLEX LP format. Each text
alpar@1
    19
line of this file may contain up to 255 characters\footnote{GLPK allows
alpar@1
    20
text lines of arbitrary length.}. Blank lines are ignored. If a line
alpar@1
    21
contains the backslash character ($\backslash$), this character and
alpar@1
    22
everything that follows it until the end of line are considered as a
alpar@1
    23
comment and also ignored.
alpar@1
    24
alpar@1
    25
An LP file is coded by the user using the following elements:
alpar@1
    26
alpar@1
    27
$\bullet$ keywords;
alpar@1
    28
alpar@1
    29
$\bullet$ symbolic names;
alpar@1
    30
alpar@1
    31
$\bullet$ numeric constants;
alpar@1
    32
alpar@1
    33
$\bullet$ delimiters;
alpar@1
    34
alpar@1
    35
$\bullet$ blanks.
alpar@1
    36
alpar@1
    37
\newpage
alpar@1
    38
alpar@1
    39
{\it Keywords} which may be used in the LP file are the following:
alpar@1
    40
alpar@1
    41
\begin{verbatim}
alpar@1
    42
      minimize        minimum        min
alpar@1
    43
      maximize        maximum        max
alpar@1
    44
      subject to      such that      s.t.      st.      st
alpar@1
    45
      bounds          bound
alpar@1
    46
      general         generals       gen
alpar@1
    47
      integer         integers       int
alpar@1
    48
      binary          binaries       bin
alpar@1
    49
      infinity        inf
alpar@1
    50
      free
alpar@1
    51
      end
alpar@1
    52
\end{verbatim}
alpar@1
    53
alpar@1
    54
\noindent
alpar@1
    55
All the keywords are case insensitive. Keywords given above on the same
alpar@1
    56
line are equivalent. Any keyword (except \verb|infinity|, \verb|inf|,
alpar@1
    57
and \verb|free|) being used in the LP file must start at the beginning
alpar@1
    58
of a text line.
alpar@1
    59
alpar@1
    60
{\it Symbolic names} are used to identify the objective function,
alpar@1
    61
constraints (rows), and variables (columns). All symbolic names are case
alpar@1
    62
sensitive and may contain up to 16 alphanumeric characters\footnote{GLPK
alpar@1
    63
allows symbolic names having up to 255 characters.} (\verb|a|, \dots,
alpar@1
    64
\verb|z|, \verb|A|, \dots, \verb|Z|, \verb|0|, \dots, \verb|9|) as well
alpar@1
    65
as the following characters:
alpar@1
    66
alpar@1
    67
\begin{verbatim}
alpar@1
    68
!  "  #  $  %  &  (  )  /  ,  .  ;  ?  @  _  `  '  {  }  |  ~
alpar@1
    69
\end{verbatim}
alpar@1
    70
alpar@1
    71
\noindent
alpar@1
    72
with exception that no symbolic name can begin with a digit or a period.
alpar@1
    73
alpar@1
    74
{\it Numeric constants} are used to denote constraint and objective
alpar@1
    75
coefficients, right-hand sides of constraints, and bounds of variables.
alpar@1
    76
They are coded in the standard form $xx$\verb|E|$syy$, where $xx$ is
alpar@1
    77
a real number with optional decimal point, $s$ is a sign (\verb|+| or
alpar@1
    78
\verb|-|), $yy$ is an integer decimal exponent. Numeric constants may
alpar@1
    79
contain arbitrary number of characters. The exponent part is optional.
alpar@1
    80
The letter `\verb|E|' can be coded as `\verb|e|'. If the sign $s$ is
alpar@1
    81
omitted, plus is assumed.
alpar@1
    82
alpar@1
    83
{\it Delimiters} that may be used in the LP file are the following:
alpar@1
    84
alpar@1
    85
\begin{verbatim}
alpar@1
    86
      :
alpar@1
    87
      +
alpar@1
    88
      -
alpar@1
    89
      <   <=   =<
alpar@1
    90
      >   >=   =>
alpar@1
    91
      =
alpar@1
    92
\end{verbatim}
alpar@1
    93
alpar@1
    94
\noindent
alpar@1
    95
Delimiters given above on the same line are equivalent. The meaning of
alpar@1
    96
the delimiters will be explained below.
alpar@1
    97
alpar@1
    98
{\it Blanks} are non-significant characters. They may be used freely to
alpar@1
    99
improve readability of the LP file. Besides, blanks should be used to
alpar@1
   100
separate elements from each other if there is no other way to do that
alpar@1
   101
(for example, to separate a keyword from a following symbolic name).
alpar@1
   102
alpar@1
   103
The order of an LP file is:
alpar@1
   104
alpar@1
   105
$\bullet$ objective function definition;
alpar@1
   106
alpar@1
   107
$\bullet$ constraints section;
alpar@1
   108
alpar@1
   109
$\bullet$ bounds section;
alpar@1
   110
alpar@1
   111
$\bullet$ general, integer, and binary sections (can appear in arbitrary
alpar@1
   112
order);
alpar@1
   113
alpar@1
   114
$\bullet$ end keyword.
alpar@1
   115
alpar@1
   116
These components are discussed in following sections.
alpar@1
   117
alpar@1
   118
\section{Objective function definition}
alpar@1
   119
alpar@1
   120
The objective function definition must appear first in the LP file. It
alpar@1
   121
defines the objective function and specifies the optimization direction.
alpar@1
   122
alpar@1
   123
The objective function definition has the following form:
alpar@1
   124
$$
alpar@1
   125
\left\{
alpar@1
   126
\begin{array}{@{}c@{}}
alpar@1
   127
{\tt minimize} \\ {\tt maximize}
alpar@1
   128
\end{array}
alpar@1
   129
\right\}\ f\ {\tt :}\ s\ c\ x\ s\ c\ x\ \dots\ s\ c\ x
alpar@1
   130
$$
alpar@1
   131
where $f$ is a symbolic name of the objective function, $s$ is a sign
alpar@1
   132
\verb|+| or \verb|-|, $c$ is a numeric constant that denotes an
alpar@1
   133
objective coefficient, $x$ is a symbolic name of a variable.
alpar@1
   134
alpar@1
   135
If necessary, the objective function definition can be continued on as
alpar@1
   136
many text lines as desired.
alpar@1
   137
alpar@1
   138
The name of the objective function is optional and may be omitted
alpar@1
   139
(together with the semicolon that follows it). In this case the default
alpar@1
   140
name `\verb|obj|' is assigned to the objective function.
alpar@1
   141
alpar@1
   142
If the very first sign $s$ is omitted, the sign plus is assumed. Other
alpar@1
   143
signs cannot be omitted.
alpar@1
   144
alpar@1
   145
If some objective coefficient $c$ is omitted, 1 is assumed.
alpar@1
   146
alpar@1
   147
Symbolic names $x$ used to denote variables are recognized by context
alpar@1
   148
and therefore needn't to be declared somewhere else.
alpar@1
   149
alpar@1
   150
Here is an example of the objective function definition:
alpar@1
   151
alpar@1
   152
\begin{verbatim}
alpar@1
   153
   Minimize Z : - x1 + 2 x2 - 3.5 x3 + 4.997e3x(4) + x5 + x6 +
alpar@1
   154
      x7 - .01x8
alpar@1
   155
\end{verbatim}
alpar@1
   156
alpar@1
   157
\section{Constraints section}
alpar@1
   158
alpar@1
   159
The constraints section must follow the objective function definition.
alpar@1
   160
It defines a system of equality and/or inequality constraints.
alpar@1
   161
alpar@1
   162
The constraint section has the following form:
alpar@1
   163
alpar@1
   164
\begin{center}
alpar@1
   165
\begin{tabular}{l}
alpar@1
   166
\verb|subject to| \\
alpar@1
   167
{\it constraint}$_1$ \\
alpar@1
   168
{\it constraint}$_2$ \\
alpar@1
   169
\hspace{20pt}\dots \\
alpar@1
   170
{\it constraint}$_m$ \\
alpar@1
   171
\end{tabular}
alpar@1
   172
\end{center}
alpar@1
   173
alpar@1
   174
\noindent where {\it constraint}$_i, i=1,\dots,m,$ is a particular
alpar@1
   175
constraint definition.
alpar@1
   176
alpar@1
   177
Each constraint definition can be continued on as many text lines as
alpar@1
   178
desired. However, each constraint definition must begin on a new line
alpar@1
   179
except the very first constraint definition which can begin on the same
alpar@1
   180
line as the keyword `\verb|subject to|'.
alpar@1
   181
alpar@1
   182
Constraint definitions have the following form:
alpar@1
   183
$$
alpar@1
   184
r\ {\tt:}\ s\ c\ x\ s\ c\ x\ \dots\ s\ c\ x
alpar@1
   185
\ \left\{
alpar@1
   186
\begin{array}{@{}c@{}}
alpar@1
   187
\mbox{\tt<=} \\ \mbox{\tt>=} \\ \mbox{\tt=}
alpar@1
   188
\end{array}
alpar@1
   189
\right\}\ b
alpar@1
   190
$$
alpar@1
   191
where $r$ is a symbolic name of a constraint, $s$ is a sign \verb|+| or
alpar@1
   192
\verb|-|, $c$ is a numeric constant that denotes a constraint
alpar@1
   193
coefficient, $x$ is a symbolic name of a variable, $b$ is a right-hand
alpar@1
   194
side.
alpar@1
   195
alpar@1
   196
The name $r$ of a constraint (which is the name of the corresponding
alpar@1
   197
auxiliary variable) is optional and may be omitted (together with the
alpar@1
   198
semicolon that follows it). In this case the default names like
alpar@1
   199
`\verb|r.nnn|' are assigned to unnamed constraints.
alpar@1
   200
alpar@1
   201
The linear form $s\ c\ x\ s\ c\ x\ \dots\ s\ c\ x$ in the left-hand
alpar@1
   202
side of a constraint definition has exactly the same meaning as in the
alpar@1
   203
case of the objective function definition (see above).
alpar@1
   204
alpar@1
   205
After the linear form one of the following delimiters that indicate
alpar@1
   206
the constraint sense must be specified:
alpar@1
   207
alpar@1
   208
\verb|<=| \ means `less than or equal to'
alpar@1
   209
alpar@1
   210
\verb|>=| \ means `greater than or equal to'
alpar@1
   211
alpar@1
   212
\verb|= | \ means `equal to'
alpar@1
   213
alpar@1
   214
The right hand side $b$ is a numeric constant with an optional sign.
alpar@1
   215
alpar@1
   216
Here is an example of the constraints section:
alpar@1
   217
alpar@1
   218
\begin{verbatim}
alpar@1
   219
   Subject To
alpar@1
   220
      one: y1 + 3 a1 - a2 - b >= 1.5
alpar@1
   221
      y2 + 2 a3 + 2
alpar@1
   222
         a4 - b >= -1.5
alpar@1
   223
      two : y4 + 3 a1 + 4 a5 - b <= +1
alpar@1
   224
      .20y5 + 5 a2 - b = 0
alpar@1
   225
      1.7 y6 - a6 + 5 a777 - b >= 1
alpar@1
   226
\end{verbatim}
alpar@1
   227
alpar@1
   228
(Should note that it is impossible to express ranged constraints in the
alpar@1
   229
CPLEX LP format. Each a ranged constraint can be coded as two
alpar@1
   230
constraints with identical linear forms in the left-hand side, one of
alpar@1
   231
which specifies a lower bound and other does an upper one of the
alpar@1
   232
original ranged constraint.)
alpar@1
   233
alpar@1
   234
\section{Bounds section}
alpar@1
   235
alpar@1
   236
The bounds section is intended to define bounds of variables. This
alpar@1
   237
section is optional; if it is specified, it must follow the constraints
alpar@1
   238
section. If the bound section is omitted, all variables are assumed to
alpar@1
   239
be non-negative (i.e. that they have zero lower bound and no upper
alpar@1
   240
bound).
alpar@1
   241
alpar@1
   242
The bounds section has the following form:
alpar@1
   243
alpar@1
   244
\begin{center}
alpar@1
   245
\begin{tabular}{l}
alpar@1
   246
\verb|bounds| \\
alpar@1
   247
{\it definition}$_1$ \\
alpar@1
   248
{\it definition}$_2$ \\
alpar@1
   249
\hspace{20pt}\dots \\
alpar@1
   250
{\it definition}$_p$ \\
alpar@1
   251
\end{tabular}
alpar@1
   252
\end{center}
alpar@1
   253
alpar@1
   254
\noindent
alpar@1
   255
where {\it definition}$_k, k=1,\dots,p,$ is a particular bound
alpar@1
   256
definition.
alpar@1
   257
alpar@1
   258
Each bound definition must begin on a new line\footnote{The GLPK
alpar@1
   259
implementation allows several bound definitions to be placed on the same
alpar@1
   260
line.} except the very first bound definition which can begin on the
alpar@1
   261
same line as the keyword `\verb|bounds|'.
alpar@1
   262
alpar@1
   263
Syntactically constraint definitions can have one of the following six
alpar@1
   264
forms:
alpar@1
   265
alpar@1
   266
\begin{center}
alpar@1
   267
\begin{tabular}{ll}
alpar@1
   268
$x$ \verb|>=| $l$ &              specifies a lower bound \\
alpar@1
   269
$l$ \verb|<=| $x$ &              specifies a lower bound \\
alpar@1
   270
$x$ \verb|<=| $u$ &              specifies an upper bound \\
alpar@1
   271
$l$ \verb|<=| $x$ \verb|<=| $u$ &specifies both lower and upper bounds\\
alpar@1
   272
$x$ \verb|=| $t$                &specifies a fixed value \\
alpar@1
   273
$x$ \verb|free|                 &specifies free variable
alpar@1
   274
\end{tabular}
alpar@1
   275
\end{center}
alpar@1
   276
alpar@1
   277
\noindent
alpar@1
   278
where $x$ is a symbolic name of a variable, $l$ is a numeric constant
alpar@1
   279
with an optional sign that defines a lower bound of the variable or
alpar@1
   280
\verb|-inf| that means that the variable has no lower bound, $u$ is a
alpar@1
   281
numeric constant with an optional sign that defines an upper bound of
alpar@1
   282
the variable or \verb|+inf| that means that the variable has no upper
alpar@1
   283
bound, $t$ is a numeric constant with an optional sign that defines a
alpar@1
   284
fixed value of the variable.
alpar@1
   285
alpar@1
   286
By default all variables are non-negative, i.e. have zero lower bound
alpar@1
   287
and no upper bound. Therefore definitions of these default bounds can be
alpar@1
   288
omitted in the bounds section.
alpar@1
   289
alpar@1
   290
Here is an example of the bounds section:
alpar@1
   291
alpar@1
   292
\begin{verbatim}
alpar@1
   293
   Bounds
alpar@1
   294
      -inf <= a1 <= 100
alpar@1
   295
      -100 <= a2
alpar@1
   296
      b <= 100
alpar@1
   297
      x2 = +123.456
alpar@1
   298
      x3 free
alpar@1
   299
\end{verbatim}
alpar@1
   300
alpar@1
   301
\section{General, integer, and binary sections}
alpar@1
   302
alpar@1
   303
The general, integer, and binary sections are intended to define
alpar@1
   304
some variables as integer or binary. All these sections are optional
alpar@1
   305
and needed only in case of MIP problems. If they are specified, they
alpar@1
   306
must follow the bounds section or, if the latter is omitted, the
alpar@1
   307
constraints section.
alpar@1
   308
alpar@1
   309
All the general, integer, and binary sections have the same form as
alpar@1
   310
follows:
alpar@1
   311
alpar@1
   312
\begin{center}
alpar@1
   313
\begin{tabular}{l}
alpar@1
   314
$
alpar@1
   315
\left\{
alpar@1
   316
\begin{array}{@{}l@{}}
alpar@1
   317
\verb|general| \\
alpar@1
   318
\verb|integer| \\
alpar@1
   319
\verb|binary | \\
alpar@1
   320
\end{array}
alpar@1
   321
\right\}
alpar@1
   322
$ \\
alpar@1
   323
\hspace{10pt}$x_1$ \\
alpar@1
   324
\hspace{10pt}$x_2$ \\
alpar@1
   325
\hspace{10pt}\dots \\
alpar@1
   326
\hspace{10pt}$x_q$ \\
alpar@1
   327
\end{tabular}
alpar@1
   328
\end{center}
alpar@1
   329
alpar@1
   330
\noindent
alpar@1
   331
where $x_k$ is a symbolic name of variable, $k=1,\dots,q$.
alpar@1
   332
alpar@1
   333
Each symbolic name must begin on a new line\footnote{The GLPK
alpar@1
   334
implementation allows several symbolic names to be placed on the same
alpar@1
   335
line.} except the very first symbolic name which can begin on the same
alpar@1
   336
line as the keyword `\verb|general|', `\verb|integer|', or
alpar@1
   337
`\verb|binary|'.
alpar@1
   338
alpar@1
   339
If a variable appears in the general or the integer section, it is
alpar@1
   340
assumed to be general integer variable. If a variable appears in the
alpar@1
   341
binary section, it is assumed to be binary variable, i.e. an integer
alpar@1
   342
variable whose lower bound is zero and upper bound is one. (Note that
alpar@1
   343
if bounds of a variable are specified in the bounds section and then
alpar@1
   344
the variable appears in the binary section, its previously specified
alpar@1
   345
bounds are ignored.)
alpar@1
   346
alpar@1
   347
Here is an example of the integer section:
alpar@1
   348
alpar@1
   349
\begin{verbatim}
alpar@1
   350
   Integer
alpar@1
   351
      z12
alpar@1
   352
      z22
alpar@1
   353
      z35
alpar@1
   354
\end{verbatim}
alpar@1
   355
alpar@1
   356
\section{End keyword}
alpar@1
   357
alpar@1
   358
The keyword `\verb|end|' is intended to end the LP file. It must begin
alpar@1
   359
on a separate line and no other elements (except comments and blank
alpar@1
   360
lines) must follow it. Although this keyword is optional, it is strongly
alpar@1
   361
recommended to include it in the LP file.
alpar@1
   362
alpar@1
   363
\section{Example of CPLEX LP file}
alpar@1
   364
alpar@1
   365
Here is a complete example of CPLEX LP file that corresponds to the
alpar@1
   366
example given in Section \ref{secmpsex}, page \pageref{secmpsex}.
alpar@1
   367
alpar@1
   368
{\footnotesize
alpar@1
   369
\begin{verbatim}
alpar@1
   370
\* plan.lp *\
alpar@1
   371
alpar@1
   372
Minimize
alpar@1
   373
   value: .03 bin1 + .08 bin2 + .17 bin3 + .12 bin4 + .15 bin5 +
alpar@1
   374
          .21 alum + .38 silicon
alpar@1
   375
alpar@1
   376
Subject To
alpar@1
   377
   yield:     bin1 +     bin2 +     bin3 +     bin4 +     bin5 +
alpar@1
   378
              alum +     silicon                                 =  2000
alpar@1
   379
alpar@1
   380
   fe:    .15 bin1 + .04 bin2 + .02 bin3 + .04 bin4 + .02 bin5 +
alpar@1
   381
          .01 alum + .03 silicon                                 <=   60
alpar@1
   382
alpar@1
   383
   cu:    .03 bin1 + .05 bin2 + .08 bin3 + .02 bin4 + .06 bin5 +
alpar@1
   384
          .01 alum                                               <=  100
alpar@1
   385
alpar@1
   386
   mn:    .02 bin1 + .04 bin2 + .01 bin3 + .02 bin4 + .02 bin5   <=   40
alpar@1
   387
alpar@1
   388
   mg:    .02 bin1 + .03 bin2                       + .01 bin5   <=   30
alpar@1
   389
alpar@1
   390
   al:    .70 bin1 + .75 bin2 + .80 bin3 + .75 bin4 + .80 bin5 +
alpar@1
   391
          .97 alum                                               >= 1500
alpar@1
   392
alpar@1
   393
   si1:   .02 bin1 + .06 bin2 + .08 bin3 + .12 bin4 + .02 bin5 +
alpar@1
   394
          .01 alum + .97 silicon                                 >=  250
alpar@1
   395
alpar@1
   396
   si2:   .02 bin1 + .06 bin2 + .08 bin3 + .12 bin4 + .02 bin5 +
alpar@1
   397
          .01 alum + .97 silicon                                 <=  300
alpar@1
   398
alpar@1
   399
Bounds
alpar@1
   400
          bin1 <=  200
alpar@1
   401
          bin2 <= 2500
alpar@1
   402
   400 <= bin3 <=  800
alpar@1
   403
   100 <= bin4 <=  700
alpar@1
   404
          bin5 <= 1500
alpar@1
   405
alpar@1
   406
End
alpar@1
   407
alpar@1
   408
\* eof *\
alpar@1
   409
\end{verbatim}
alpar@1
   410
alpar@1
   411
}
alpar@1
   412
alpar@1
   413
%* eof *%