CPXXreadcopyprob and CPXreadcopyprob

The routine CPXXreadcopyprob/CPXreadcopyprob reads an MPS, LP, or SAV file into an existing CPLEX problem object.

int  CPXXreadcopyprob( CPXCENVptr env, CPXLPptr lp, char const * filename_str, char const * filetype )

int  CPXreadcopyprob( CPXCENVptr env, CPXLPptr lp, char const * filename_str, char const * filetype )

Description

The routine CPXXreadcopyprob/CPXreadcopyprob reads an MPS, LP, or SAV file into an existing CPLEX problem object. Any existing data associated with the problem object is destroyed. The problem can then be optimized by any one of the optimization routines. To determine the contents of the data, use CPLEX query routines.

The type of the file may be specified with the filetype argument. When the filetype argument is NULL, the file name is checked for one of these suffixes: .lp, .mps, or .sav. CPLEX will also look for the following additional optional suffixes: .gz or .bz2.

If the file name matches one of these patterns, filetype is set accordingly. If filetype is NULL and none of these strings is found at the end of the file name, or if the specified type is not recognized, CPLEX attempts automatically to detect the type of the file by examining the first few bytes.

If the file name ends in .gz or .bz2, the file is read as a compressed file. Thus, a file name ending in .sav is read as a SAV format file, while a file name ending in .sav.gz is read as a compressed SAV format file.

Table 1. Values of filetype
SAV Use SAV format
MPS Use MPS format
LP Use LP format

Arguments

env
A pointer to the CPLEX environment as returned by CPXXopenCPLEX/CPXopenCPLEX.
lp
A pointer to a CPLEX problem object as returned by CPXXcreateprob/CPXcreateprob.
filename_str
The name of the file from which the problem should be read.
filetype
A case-insensitive string containing the type of the file (one of the strings in the table). May be NULL, in which case the file type is inferred from the last characters of the file name.

Return

The routine returns 0 (zero) if successful and nonzero if an error occurs.

Example


status = CPXreadcopyprob (env, lp, "myprob.mps", NULL);

See also the example lpex2.c in the CPLEX User's Manual and in the standard distribution.