next up previous contents
Next: OSUtils Up: The OS Library Components Previous: OSParsers   Contents


OSSolverInterfaces

The OSSolverInterfaces library is designed to facilitate linking the OS library with various solver APIs. We first describe how to take a problem instance in OSiL format and connect to a solver that has a COIN-OR OSI interface. See the OSI project www.projects.coin-or.org/Osi. We then describe hooking to the COIN-OR nonlinear code Ipopt. See www.projects.coin-or.org/Ipopt. Finally we describe hooking to two commercial solvers KNITRO and LINDO.

The OS library has been tested with the following solvers using the Osi Interface.

In the OSSolverInterfaces library there is an abstract class DefaultSolver that has the following key members:

std::string osil;
std::string osol;
std::string osrl;
OSInstance *osinstance;
OSResult  *osresult;
and the pure virtual function
virtual void solve() = 0 ;
In order to use a solver through the COIN-OR Osi interface it is necessary to create an object in the CoinSolver class which inherits from the DefaultSolver class and implements the appropriate solve() function. We illustrate with the Clp solver.

DefaultSolver *solver  = NULL;
solver = new CoinSolver();
solver->m_sSolverName = "clp";

Assume that the data file containing the problem has been read into the string osil and the solver options are in the string osol. Then the Clp solver is invoked as follows.

solver->osil = osil;
solver->osol = osol;
solver->solve();

Finally, get the solution in OSrL format as follows

cout << solver->osrl << endl;

Even though LINDO and KNITRO are commercial solvers and do not have a COIN-OR Osi interface these solvers are used in exactly the same manner as a COIN-OR solver. For example, to invoke the LINDO solver we do the following.

solver = new LindoSolver();

Similarly for KNITRO and Ipopt. In the case of KNITRO, the KnitroSolver class inherits from both DefaultSolver class and the KNITRO NlpProblemDef class. See http://www.ziena.com/docs/knitroman.pdf for more information on the KNITRO solver C++ implementation and the NlpProblemDef class. Similarly, for Ipopt the IpoptSolver class inherits from both the DefaultSolver class and the Ipopt TNLP class. See https://projects.coin-or.org/Ipopt/browser/stable/3.2/Ipopt/doc/documentation.pdf?format=raw for more information on the Ipopt solver C++ implementation and the TNLP calss.

In the examples above, the problem instance was assumed to be read from a file into the string osil and then into the class member solver->osil. However, everything can be done entirely in memory. For example, it is possible to use the OSInstance class to create an in-memory problem representation and give this representation directly to a solver class that inherits from DefaultSolver. The class member to use is osinstance. This is illustrated in the example given in Section 13.3.


next up previous contents
Next: OSUtils Up: The OS Library Components Previous: OSParsers   Contents
Kipp Martin 2008-01-16