<br><font size=2 face="sans-serif">James,</font>
<br>
<br><font size=2 face="sans-serif">I was not paying attention as I saw
readLp and thought - that is nothing to do with Clp/OsiClp.</font>
<br>
<br><font size=2 face="sans-serif">I will put readLp and writeLp into OsiClp.</font>
<br>
<br><font size=2 face="sans-serif">John Forrest</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>"James Gibbons"
<James.Gibbons@nottingham.ac.uk></b> </font>
<br><font size=1 face="sans-serif">Sent by: coin-discuss-bounces@list.coin-or.org</font>
<p><font size=1 face="sans-serif">02/01/2006 09:27 AM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
Discussions about open source software for Operations Research
<coin-discuss@list.coin-or.org></font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif"><coin-discuss@list.coin-or.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">[Coin-discuss] re: Preserving row and
column names using readLP & OsiSolverInterface</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><tt><font size=2>Dear All,<br>
<br>
Replying to myself about previous message (text at end). Investigating
further I don't think the OsiSolverInterface::readLp function, inherited
by OsiClpSolverInterface copies the neames into the Solver object. I've
fixed this problem for me locally by adding the following function
to OsiClpSolverInterface.cpp (and a corresponding declaration in OsiClpSolverInterface.hpp).
the function is adapted from OsiSolverInterface::readLp and OsiClpSolverInterface::readMps.
I guess there maybe a more elegant way of doing this as the message handler
stuff doesn't work and CoinLpIO::readLp doesn't return the number of errors.
Is there any chane of getting this or an improved version included in the
code base?<br>
<br>
Thanks,<br>
<br>
James <br>
<br>
int<br>
OsiClpSolverInterface::readLp(const char * filename, const double epsilon)<br>
{<br>
<br>
// Get rid of integer stuff<br>
delete [] integerInformation_;<br>
integerInformation_=NULL;<br>
<br>
CoinLpIO m;<br>
m.setInfinity(getInfinity());<br>
//m.passInMessageHandler(modelPtr_->messageHandler());<br>
//*m.messagesPointer()=modelPtr_->coinMessages();<br>
<br>
//handler_->message(COIN_SOLVER_MPS,messages_)<br>
// <<m.getProblemName()<< numberErrors <<CoinMessageEol;<br>
int numberErrors = 0;<br>
m.readLp(filename, epsilon);<br>
<br>
if (!numberErrors) {<br>
// set objective function offest<br>
setDblParam(OsiObjOffset, 0);<br>
<br>
// set problem name<br>
setStrParam(OsiProbName, m.getProblemName());<br>
<br>
// no errors<br>
loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(),<br>
m.getObjCoefficients(),m.getRowSense(),m.getRightHandSide(),<br>
m.getRowRange());<br>
<br>
const char *integer = m.integerColumns();<br>
int nCols = m.getNumCols();<br>
int nRows = m.getNumRows();<br>
if (integer) {<br>
int
i, n = 0;<br>
int
*index = new int [nCols];<br>
for
(i=0; i<nCols; i++) {<br>
if (integer[i]) {<br>
index[n++]
= i;<br>
}<br>
}<br>
setInteger(index,n);<br>
delete
[] index;<br>
}<br>
<br>
// Always keep names<br>
int iRow;<br>
std::vector<std::string> rowNames = std::vector<std::string>
();<br>
std::vector<std::string> columnNames = std::vector<std::string>
();<br>
rowNames.reserve(nRows);<br>
for (iRow=0;iRow<nRows;iRow++) {<br>
const
char * name = m.rowName(iRow);<br>
rowNames.push_back(name);<br>
}<br>
<br>
int iColumn;<br>
columnNames.reserve(nCols);<br>
for (iColumn=0;iColumn<nCols;iColumn++) {<br>
const
char * name = m.columnName(iColumn);<br>
columnNames.push_back(name);<br>
}<br>
modelPtr_->copyNames(rowNames,columnNames);<br>
}<br>
return numberErrors; <br>
<br>
Dear all,<br>
<br>
I am trying to use the Clp and Cbc solvers to solve a problem generated
by XpressMP Mosel. I have been able to read and solve the problem as a
.lp file but not using a .mps file. (I think Xpress mps files might have
a non-standard extension to the format?).<br>
<br>
What I can't work out how to do is too keep the row and column names from
the original problem. A simple example:<br>
<br>
OsiClpSolverInterface solver0;<br>
std::string fn = "test2.lp";<br>
solver0.readLp(fn.c_str());<br>
int ncols = solver0.getNumCols();<br>
for(int i=0;i<ncols;i++) {<br>
std::cout<<solver0.getColName(i)<<"\n";}<br>
<br>
This outputs the column names as C0000001 etc. As there is no guarantee
about what order Mosel generates the matrix in I really need access
to the names. I've tried recompiling with LPIO_DEBUG defined in the CoinLPIO.cpp
file and the output from this suggests that readLp is reading in the problem
names correctly. So am I missing something obvious or doing something wrong?<br>
<br>
Thanks,<br>
<br>
James<br>
<br>
This message has been checked for viruses but the contents of an attachment<br>
may still contain software viruses, which could damage your computer system:<br>
you are advised to perform your own checks. Email communications with the<br>
University of Nottingham may be monitored as permitted by UK legislation.<br>
<br>
<br>
_______________________________________________<br>
Coin-discuss mailing list<br>
Coin-discuss@list.coin-or.org<br>
http://list.coin-or.org/mailman/listinfo/coin-discuss<br>
</font></tt>
<br>