In example ilolpex1.cpp
we left one line unexplained:
cplex.exportModel("lpex1.lp"); |
This statement causes cplex
to write the model it has currently extracted to the file called lpex1.lp
. In this case, the file will be written in LP format (whose usage is described in detail in the ILOG CPLEX Reference Manual). Other formats supported for writing problems to a file are MPS and SAV (also described in the ILOG CPLEX Reference Manual). IloCplex
decides which file format to write based on the extension of the file name.
IloCplex
also supports reading of files through one of its importModel
methods. A call to cplex.importModel
(model, "file.lp") causes CPLEX to read a problem from the file file.lp
and add all the data in it to model
as new objects. (Again, MPS and SAV format files are also supported.) In particular, CPLEX creates an instance of
IloObjective | |
IloNumVar | |
IloSemiContVar | |
IloRange | |
IloSOS1 | |
IloSOS2 |
void IloCplex::importModel(IloModel& m, const char* filename, IloObjective& obj, IloNumVarArray vars, IloRangeArray rngs) const; |
void IloCplex::importModel(IloModel& m, const char* filename, IloObjective& obj, IloNumVarArray vars, IloRangeArray rngs, IloSOS1Array sos1, IloSOS2Array sos2) const; |