/usr/share/doc/lp-solve-doc/Xpress-format.htm is in lp-solve-doc 5.5.0.13-7build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<HEAD>
<TITLE>Xpress lp files</TITLE>
<style TYPE="text/css"> BODY { font-family:verdana,arial,helvetica; margin:0; }
</style>
</HEAD>
<BODY>
<TABLE STYLE="TABLE-LAYOUT:fixed" class="clsContainer" CELLPADDING="15" CELLSPACING="0"
WIDTH="100%" BORDER="0">
<TR>
<TD VALIGN="top">
<p><h1 align="left"><u>Xpress lp files</u></h1>
<p>The Xpress LP file format provides a facility for entering a problem in a
natural, algebraic LP formulation from the keyboard. The problem can be
modified and saved from within lpsolve. This procedure is one way to create a
file in a format that lpsolve can read. An alternative technique is to create a
similar file using a standard text editor and to read it into lpsolve.</p>
<P>The Xpress LP format is provided as an input alternative to the MPS file format.
An LP format file may be easier to generate than an MPS file if your problem
already exists in an algebraic format or if you have an application that
generates the problem file more readily in algebraic format (such as a C
application).</P>
<p>Note that the Xpress LP format is not the same as the lpsolve LP format.
See <a href="lp-format.htm">LP file format</a> for a description about
the native lpsolve lp format. To read/write this format from lpsolve, you need
an XLI (see <a href="XLI.htm">External Language Interfaces</a>). The XLI for the Xpress
format is called xli_Xpress.</p>
<h3>Options</h3>
<p>The XLI accepts several options:</p>
<h4>Reading</h4>
<pre>
-objconst Allow constants in the objective (default).
-noobjconst Don't allow constants in the objective.
</pre>
<p>From the documentation of the format it is not sure if Xpress allows a constant
in the objective. Tests have shown that it allows a constant as first term in
the objective function.
Note that the lp_solve XLI allows a constant in the objective by default and it can be
anywere in the objective.
Use the option -noobjconst if this should not be allowed.
The parser will then give an error.</p>
<h4>Writing</h4>
<pre>
-objconst Allow constants in the objective.
-noobjconst Don't use constants in the objective (default).
</pre>
<p>From the documentation of the format it is not sure if Xpress allows a constant
in the objective. Tests have shown that it allows a constant as first term in
the objective function.
The lp_solve XLI writes the constant as first term when the option -objconst is active.
By default or when the option -noobjconst is used, a constant in the objective
is translated to a variable objconst_term with a bound equal to the constant set
to it. So no error is generated when there is a constant.</p>
<h3>Example</h3>
<pre>
lp_solve -rxli xli_Xpress input.lp
lp_solve -mps input.mps -wxli xli_Xpress output.lp -wxliopt "-objconst"
</pre>
<h3>Syntax Rules of LP File Format</h3>
<P>lpsolve will accept any problem saved in an ASCII file provided that it adheres
to the following syntax rules.
</P>
<ol>
<li><p><b>Comments and blank lines</b></p>
<p>
Text following a backslash (\) and up to the subsequent carriage return is treated as a comment.
Blank lines are ignored. Blank lines and comments may be inserted anywhere in an .lp
file. For example, a common comment to put in LP files is the name of the problem:
</p>
<BLOCKQUOTE>
<pre>
\Problem name: prob01
</pre>
</BLOCKQUOTE>
</li>
<li><p><b>File lines, white space and identifiers</b></p>
<p>
White space and carriage returns delimit variable names and keywords from other identifiers.
Keywords are case insensitive. Variable names are case sensitive. Although it is not strictly
necessary, for clarity of your LP files it is perhaps best to put your section keywords on their
own lines starting at the first character position on the line. No
line continuation character is needed when expressions are required to span multiple lines.
Lines may be broken for continuation wherever you may use white space.
</p>
</li>
<li><p><b>Sections</b></p>
<p>
The LP file is broken up into sections separated by section keywords. The following are a list
of section keywords you can use in your LP files. A section started by a keyword is terminated
with another section keyword indicating the start of the subsequent section.
</p>
<table width="100%" border="1">
<tr>
<th>Section keywords</th><th>Synonyms</th><th>Section contents</th>
</tr>
<tr>
<td VALIGN="top">maximize or minimize</td><td VALIGN="top">maximum<br>max<br>minimum<br>min</td><td VALIGN="top">One linear expression describing the objective function.</td>
</tr>
<tr>
<td VALIGN="top">subject to</td><td VALIGN="top">subject to:<br>such that<br>st<br>s.t.<br>st.<br>subjectto<br>suchthat<br>subject<br>such</td><td VALIGN="top">A list of constraint expressions.</td>
</tr>
<tr>
<td VALIGN="top">bounds</td><td VALIGN="top">bound</td><td VALIGN="top">A list of bounds expressions for variables.</td>
</tr>
<tr>
<td VALIGN="top">integers</td><td VALIGN="top">integer<br>ints<br>int<br></td><td VALIGN="top">A list of variable names of integer variables. Unless otherwise specified in the bounds section, the default relaxation interval of the variables is [0, 1].</td>
</tr>
<tr>
<td VALIGN="top">generals</td><td VALIGN="top">general<br>gens<br>gen<br></td><td VALIGN="top">A list of variable names of integer variables. Unless otherwise specified in the bounds section, the default relaxation interval of the variables is [0, infinite].</td>
</tr>
<tr>
<td VALIGN="top">binaries</td><td VALIGN="top">binary<br>bins<br>bin<br></td><td VALIGN="top">A list of variable names of binary variables.</td>
</tr>
<tr>
<td VALIGN="top">semi-continuous</td><td VALIGN="top">semi<br>continuous<br>semis<br>semi<br>s.c.<br></td><td VALIGN="top">A list of variable names of semicontinuous variables.</td>
</tr>
<tr>
<td VALIGN="top">semi integer</td><td VALIGN="top">s.i.</td><td VALIGN="top">A list of variable names of semiinteger variables.</td>
</tr>
<tr>
<td VALIGN="top">partial integer</td><td VALIGN="top">p.i.</td><td VALIGN="top">A list of variable names of partial integer variables.<br><b>Not supported by lp_solve</b></td>
</tr>
</table>
<p>
Variables that do not appear in any of the variable type registration sections (i.e., integers,
generals, binaries, semi-continuous, semi integer, partial integer) are defined
to be continuous variables by default. That is, there is no section defining variables to be
continuous variables.
</p>
<p>
With the exception of the objective function section (maximize or minimize) and the constraints
section (subject to), which must appear as the first and second sections respectively,
the sections may appear in any order in the file. The only mandatory section is the objective
function section. Note that you can define the objective function to be a constant in which
case the problem is a so-called constraint satisfaction problem. The following two examples of
LP file contents express empty problems with constant objective functions and no variables or
constraints.
</p>
<p>
Empty problem 1:
</p>
<BLOCKQUOTE>
<pre>
Minimize
End
</pre>
</BLOCKQUOTE>
<p>
Empty problem 2:
</p>
<BLOCKQUOTE>
<pre>
Minimize
0
End
</pre>
</BLOCKQUOTE>
<p>
The end of a matrix description in an LP file can be indicated with the keyword end entered
on a line by itself. This can be useful for allowing the remainder of the file for storage of
comments, unused matrix definition information or other data that may be of interest to be
kept together with the LP file.
</p>
</li>
<li><p><b>Variable names</b></p>
<p>
Variable names can use any of the alphanumeric characters (a-z, A-Z, 0-9) and any of the following
symbols:
</p>
<BLOCKQUOTE>
<pre>
!"#$%&/,.;?@_`ยด{}()|~'
</pre>
</BLOCKQUOTE>
<p>
A variable name can not begin with a number or a period. Care should be taken using the
characters E or e since these may be interpreted as exponential notation for numbers.
</p>
</li>
<li><p><b>Linear expressions</b></p>
<p>
Linear expressions are used to define the objective function and constraints. Terms in a linear
expression must be separated by either a + or a - indicating addition or subtraction of the
following term in the expression. A term in a linear expression is either a variable name or a
numerical coefficient followed by a variable name. It is not necessary to separate the coefficient
and its variable with white space or a carriage return although it is advisable to do so
since this can lead to confusion. For example, the string " 2e3x" in an LP file is interpreted using
exponential notation as 2000 multiplied by variable x rather than 2 multiplied by variable
e3x. Coefficients must precede their associated variable names. If a coefficient is omitted it is
assumed to be 1.
</p>
</li>
<li><p><b>Objective function</b></p>
<p>
The objective function section can be written in a similar way to the following examples using
either of the keywords maximize or minimize. Note that the keywords maximize and
minimize are not used for anything other than to indicate the following linear expression to
be the objective function. Note the following two examples of an LP file objective definition:
</p>
<BLOCKQUOTE>
<pre>
Maximize
- 1 x1 + 2 x2 + 3x + 4y
</pre>
</BLOCKQUOTE>
<p>
or
</p>
<BLOCKQUOTE>
<pre>
Minimize
- 1 x1 + 2 x2 + 3x + 4y
</pre>
</BLOCKQUOTE>
<p>
Generally objective functions are defined using many terms and thus the objective function definitions are typically always
broken with line continuations. No line continuation character is required and lines may be
broken for continuation wherever you may use white space.
</p>
<p>
The objective function can be named in the same way as for constraints (see later).
</p>
</li>
<li><p><b>Constraints</b></p>
<p>
The section of the LP file defining the constraints is preceded by the keyword subject to.
Each constraint definition must begin on a new line. A constraint may be named with an
identifier followed by a colon before the constraint expression. Constraint names must follow
the same rules as variable names. If no constraint name is specified for a constraint then a
default name is assigned. Constraint names
are trimmed of white space before being stored.
The constraints are defined as a linear expression in the variables followed by an indicator
of the constraint's sense and a numerical right-hand side coefficient. The constraint sense is
indicated intuitively using one of the tokens: >=, <=, or =. For example, here is a named
constraint:
</p>
<BLOCKQUOTE>
<pre>
depot01: - x1 + 1.6 x2 - 1.7 x3 <= 40
</pre>
</BLOCKQUOTE>
<p>
Note that tokens > and < can be used, respectively, in place of the tokens >= and <=.
</p>
<p>
Generally, constraints are defined using many terms so the constraint definitions are typically broken with
line continuations. No line continuation character is required and lines may be broken for
continuation wherever you may use white space.
</p>
</li>
<li><p><b>Bounds</b></p>
<p>
The list of bounds in the bounds section are preceded by the keyword bounds. Each bound
definition must begin on a new line. Single or double bounds can be defined for variables.
Double bounds can be defined on the same line as 10 <= x <= 15 or on separate lines in the
following ways:
</p>
<BLOCKQUOTE>
<pre>
10 <= x
15 >= x
</pre>
</BLOCKQUOTE>
<p>
or
</p>
<BLOCKQUOTE>
<pre>
x >= 10
x <= 15
</pre>
</BLOCKQUOTE>
<p>
If no bounds are defined for a variable, default lower and upper
bounds are used. An important point to note is that the default bounds are different for different
types of variables. For continuous variables the interval defined by the default bounds is [0,
infinity] while for variables declared in the integers and generals section
(see later) the relaxation interval defined by the default bounds is [0, 1] and [0, infinity],
respectively.</p>
<p>
If a single bound is defined for a variable the appropriate default
bounds are used as the second bound. Note that negative upper bounds on variables must be declared
together with an explicit definition of the lower bound for the variable. Also note that variables
can not be declared in the bounds section. That is, a variable appearing in a bounds
section that does not appear in a constraint in the constraint section is ignored.
</p>
<p>
Bounds that fix a variable can be entered as simple equalities. For example, x6 = 7.8 is equivalent
to 7.8 <= x6 <= 7.8. The bounds +inf (positive infinity) and -inf (negative infinity) must be
entered as strings (case insensitive):
</p>
<BLOCKQUOTE>
<pre>
+infinity, -infinity, +inf, -inf.
</pre>
</BLOCKQUOTE>
<p>
Note that the keywords infinity and inf may not be used as a right-hand side coefficient of
a constraint.
</p>
<p>
A variable with a negative infinity lower bound and positive infinity upper bound may be entered
as free (case insensitive). For example, x9 free in an LP file bounds section is equivalent
to:
</p>
<BLOCKQUOTE>
<pre>
- infinity <= x9 <= + infinity
</pre>
</BLOCKQUOTE>
<p>
or
</p>
<BLOCKQUOTE>
<pre>
- infinity <= x9
</pre>
</BLOCKQUOTE>
<p>
In the last example here, which uses a single bound is used for x9 (which is positive infinity for
continuous example variable x9).
</p>
<li><p><b>Generals, Integers and binaries</b></p>
<p>
The generals, integers and binaries sections of an LP file is used to indicate the variables
that must have integer values in a feasible solution. The difference between the variables
registered in each of these sections is in the definition of the default bounds that the variables
will have. For variables registered in the generals section the default bounds are 0 and
infinity. For variables registered in the integers section the default bounds are 0 and
1. The bounds for variables registered in the binaries section are 0 and 1.
</p>
<p>
The lines in the generals, integers and binaries sections are a list of white space or carriage
return delimited variable names. Note that variables can not be declared in these sections.
That is, a variable appearing in one of these sections that does not appear in a constraint
in the constraint section is ignored.
</p>
<li><p><b>Semi-continuous and semi-integer</b></p>
<p>
The semi-continuous and semi integer sections of an LP file relate to two similar classes
of variables and so their details are documented here simultaneously.
</p>
<p>
The semi-continuous (or semi integer) section of an LP file are used to specify variables as
semi-continuous (or semi-integer) variables, that is, as variables that may take either (a) value 0
or (b) real (or integer) values from specified thresholds and up to the variables' upper bounds.
</p>
<p>
The lines in a semi-continuous (or semi integer) section are a list of white space or carriage
return delimited entries that are either (i) a variable name or (ii) a variable name-number
pair. The following example shows the format of entries in the semi-continuous section.
</p>
<BLOCKQUOTE>
<pre>
Semi-continuous
x7 >= 2.3
x8
x9 >= 4.5
</pre>
</BLOCKQUOTE>
<p>
The following example shows the format of entries in the semi integer section.
</p>
<BLOCKQUOTE>
<pre>
Semi integer
x7 >= 3
x8
x9 >= 5
</pre>
</BLOCKQUOTE>
<p>
Note that you can not use the <= token in place of the >= token.
</p>
<p>
The threshold of the interval within which a variable may have real (or integer) values is defined in two ways depending on whether the entry for the variable is (i) a variable name or (ii)
a variable name-number pair. If the entry is just a variable name, then the variable's threshold
is the variable's lower bound, defined in the bounds section (see earlier). If the entry for a
variable is a variable name-number pair, then the variable's threshold is the number value in
the pair.
</p>
<p>
It is important to note that if (a) the threshold of a variable is defined by a variable namenumber
pair and (b) a lower bound on the variable is defined in the bounds section, then:
</p>
<p>
Case 1) If the lower bound is less then zero, then the lower bound is zero.
</p>
<p>
Case 2) If the lower bound is greater than zero but less than the threshold, then the value of
zero is essentially cut off the domain of the semi-continuous (or semi-integer) variable and the
variable becomes a simple bounded continuous (or integer) variable.
</p>
<p>
Case 3) If the lower bound is greater than the threshold, then the variable becomes a simple
lower bounded continuous (or integer) variable.
</p>
<p>
If no upper bound is defined in the bounds section for a semi-continuous (or semi-integer)
variable, then the default upper bound that is used is the same as for continuous variables, for
semi-continuous variables, and generals section variables, for semi-integer variables.
</p>
<li><p><b>Partial integers</b></p>
<p>
The partial integers section of an LP file is used to specify variables as partial integer
variables, that is, as variables that can only take integer values from their lower bounds up to
specified thresholds and then take continuous values from the specified thresholds up to the
variables' upper bounds.
</p>
<p>
<b>lp_solve does not support partial integers.</b>
An error will be generated by the parser if a partial integer section is found.
</p>
<li><p><b>Special ordered sets</b></p>
<p>
Special ordered sets are defined as part of the constraints section of the LP file. The definition
of each special ordered set looks the same as a constraint except that the sense is always
= and the right hand side is either S1 or S2 (case sensitive) depending on whether the set is to
be of type 1 or 2, respectively. Special ordered sets of type 1 require that, of the non-negative
variables in the set, one at most may be non-zero. Special ordered sets of type 2 require that
at most two variables in the set may be non-zero, and if there are two non-zeros, they must be
adjacent. Adjacency is defined by the weights, which must be unique within a set given to the
variables. The weights are defined as the coefficients on the variables in the set constraint. The
sorted weights define the order of the special ordered set. It is perhaps best practice to keep
the special order sets definitions together in the LP file to indicate (for your benefit) the start
of the special ordered sets definition with the comment line \Special Ordered Sets as is
done when a problem is written to an LP file. The following example
shows the definition of a type 1 and type 2 special ordered set.
</p>
<BLOCKQUOTE>
<pre>
Sos101: 1.2 x1 + 1.3 x2 + 1.4 x4 = S1
Sos201: 1.2 x5 + 1.3 x6 + 1.4 x7 = S2
</pre>
</BLOCKQUOTE>
</ol>
<h3>Some examples</h3>
<h4>Example 1</h4>
<pre>
Minimize
COST: XONE + 4 YTWO + 9 ZTHREE + 2
Subject To
LIM1: XONE + YTWO <= 5
LIM2: XONE + ZTHREE >= 10
MYEQN: - YTWO + ZTHREE = 7
Bounds
0 <= XONE <= 4
-1 <= YTWO <= 1
End
</pre>
<h4>Example 2</h4>
<pre>
Minimize
obj: - 2 x3
Subject To
c1: x2 - x1 <= 10
c2: x1 + x2 + x3 <= 20
Bounds
x1 <= 30
2 <= x3 <= 3
s.i.
x3
x1 >= 2.1
End
</pre>
<h4>Example 3</h4>
<pre>
Minimize
obj: - 2 x3
Subject To
c1: x2 - x1 <= 10
\SOS
sos101: 4 x2 + 2 x3 = S2
c2: x1 + x2 + x3 <= 20
sos102: x1 + x2 + x3 = S1
sos201: 1.2 x3 +1.3 x2 + 1.4 x1 = S2
Bounds
x1 <= 30
2 <= x3 <= 3
End
</pre>
</TD>
</TR>
</TABLE>
</BODY>
</html>
|