Understanding File Formats

The ILOG CPLEX Reference Manual documents the file formats that ILOG CPLEX supports. Here is a brief description of these file formats:

Working with LP Files

LP files are row-oriented so you can look at a problem as you enter it in a naturally and intuitively algebraic way. However, ILOG CPLEX represents a problem internally in a column-ordered format. This difference between the way ILOG CPLEX accepts a problem in LP format and the way it stores the problem internally may have an impact on memory use and on the order in which variables are displayed on screen or in files.

Memory Use and LP Files

Whenever ILOG CPLEX reads a file in LP format, it converts from row-orientation to column-orientation. The conversion requires memory. On a platform with limited memory, if there is insufficient memory to read a given problem in LP format, there may still be sufficient memory to read the problem in MPS format. Generally, the ILOG CPLEX MPS file reader will load MPS format files more efficiently than will the LP reader loading LP format files.

Variable Order and LP Files

As ILOG CPLEX reads an LP format file by rows, it adds columns as it encounters them in a row. This convention will have an impact on the order in which variables are named and displayed. For example, consider this problem:

Maximize 

 

 
2x2 
3x3 

 

 
subject to 

 

 

 

 

 

 

 

 
-x1 
x2 
x3 
 
20 

 
x1 
3x2 
x3 
 
30 
with these bounds 

 

 

 

 

 

 
 
x1 
 
40 

 

 

 
 
x2 
 
+ 

 

 

 
 
x3 
 
+ 

 

 

Since ILOG CPLEX reads the objective function as the first row, the two columns appearing there will become the first two variables. When the problem is displayed or rewritten into another LP file, the variables there will appear in a different order within each row. In this example, if you execute the command display problem all, you will see this:

Maximize

obj: 2 x2 + 3 x3

Subject To

c1: x2 + x3 - x1 <= 20

c2: - 3 x2 + x3 + x1 <= 30

Bounds

0 <= x1 <= 40

All other variables are >= 0.

That is, x1 appears at the end of each constraint in which it has a nonzero coefficient. This re-ordering does not affect the optimal value of the problem, but you may find it disconcerting when you first encounter it.

Working with MPS Files

The ILOG CPLEX MPS file reader is highly compatible with existing modeling systems. There is generally no need to modify existing problem files to use them with ILOG CPLEX. However, there are ILOG CPLEX-specific conventions that may be useful for you to know. This section explains those conventions, and the ILOG CPLEX Reference Manual documents MPS format more fully.

Free Rows in MPS Files

In an MPS file, ILOG CPLEX selects the first free row or N-type row as the objective function, and it discards all subsequent free rows unless it is instructed otherwise by an OBJNAME section in the file. To retain free rows in an MPS file, reformulate them as equality rows with an additional free variable. For example, replace the free row x + y by the equality row x + y - s = 0 where s is free. Generally, the ILOG CPLEX presolver will remove rows like that before optimization so they will have no impact on performance.

Ranged Rows in MPS Files

To handle ranged rows, ILOG CPLEX introduces a temporary range variable, creates appropriate bounds for this variable, and changes the sense of the row to an equality (that is, MPS type EQ). The added range variables will have the same name as the ranged row with the characters Rg prefixed. When ILOG CPLEX generates solution reports, it removes these temporary range variables from the constraint matrix.

Extra Rim Vectors in MPS Files

The MPS format allows multiple right-hand sides (RHS), multiple bounds, and multiple range vectors. It also allows extra free rows. Together, these features are known as extra rim vectors. By default, the ILOG CPLEX MPS reader selects the first RHS, bound, and range definitions that it finds. The first free row (that is, N-type row) becomes the objective function, and the remaining free rows are discarded. The extra rim data are also discarded.

Naming Conventions in MPS Files

ILOG CPLEX accepts any noncontrol-character within a name. However, ILOG CPLEX recognizes blanks (that is, space) as delimiters, so you must avoid them in names. You should also avoid $ (dollar sign) and * (asterisk) as characters in names because they normally indicate a comment within a data record.

Error Checking in MPS Files

Fairly common problems in MPS files include split vectors, unnamed columns, and duplicated names. ILOG CPLEX checks for these conditions and reports them. If repeated rows or columns occur in an MPS file, ILOG CPLEX reports an error and stops reading the file. You can then edit the MPS file to correct the source of the problem.

Saving Modified MPS Files

You may often want to save a modified MPS file for later use. To that end, ILOG CPLEX will write out a problem exactly as it appears in memory. All your revisions of that problem will appear in the new file. One potential area for confusion occurs when a maximization problem is saved. Since MPS conventionally represents all problems as minimizations, ILOG CPLEX reverses the sign of the objective-function coefficients when it writes a maximization problem to an MPS file. When you read and optimize this new problem, the values of the variables will be valid for the original model. However, since the problem has been converted from a maximization to the equivalent minimization, the objective, dual, and reduced-cost values will have reversed signs.

Converting File Formats

MPS, Mathematical Programming System, an industry-standard format based on ASCII-text has historically been restricted to a fixed format in which data fields were limited to eight characters and specific fields had to appear in specific columns on specific lines. ILOG CPLEX supports extensions to MPS that allow more descriptive names (that is, more than eight characters), greater accuracy for numerical data, and greater flexibility in data positions.

Most MPS files in fixed format conform to the ILOG CPLEX extensions and thus can be read by the ILOG CPLEX MPS reader without error. However, the ILOG CPLEX MPS reader will not accept the following conventions:

You can convert fixed-format MPS files that contain those conventions into acceptable ILOG CPLEX-extended MPS files. To do so, use the convert utility supplied in the standard distribution of ILOG CPLEX. The convert utility removes unreadable features from fixed-format MPS, REW, BAS, SOS, and ORD files. It runs from the operating system prompt of your platform. Here is the syntax of the convert utility:

convert -option inputfilename outputfilename

Your command must include an input-file name and an output-file name; they must be different from each other. The options, summarized in Table 8.1, indicate the file type. You may specify only one option. If you do not specify an option, ILOG CPLEX attempts to deduce the file type from the extension in the file name.

Table 8.1 Options for the convert Utility and Corresponding File Extensions

Option 
File type 
File extension 
-m 
MPS (Mathematical Programming System) 
.mps 
-r 
REV (MIPs revise file) 
.rev 
-s 
SOS (Special Ordered Set) 
.sos 
-b 
BAS (basis file according to MPS conventions) 
.bas 
-o 
ORD (priority orders) 
.ord 


Previous Page: Managing Input & Output  Return to Top Next Page: Managing Log Files: the Log File Parameter