> Tutorials > Concert Technology Tutorial for C++ Users > Writing and Reading Models and Files |
Writing and Reading Models and Files |
INDEX
![]() |
In example ilolpex1.cpp
, one line is still unexplained:
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. (Use of that format is documented in the reference manual ILOG CPLEX File Formats.)Other formats supported for writing problems to a file are MPS and SAV (also documented in the reference manual ILOG CPLEX File Formats). 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 ILOG 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, ILOG CPLEX creates an instance of
If you also need access to the modeling objects created by importModel
, two additional signatures are provided:
void IloCplex::importModel(IloModel& m, const char* filename, IloObjective& obj, IloNumVarArray vars, IloRangeArray rngs) const; |
and
void IloCplex::importModel(IloModel& m, const char* filename, IloObjective& obj, IloNumVarArray vars, IloRangeArray rngs, IloSOS1Array sos1, IloSOS2Array sos2) const; |
They provide additional parameters so that the newly created modeling objects will be returned to the caller. Example program ilolpex2.cpp
gives an example of how to use method importModel
.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |