<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>&quot;James Gibbons&quot;
&lt;James.Gibbons@nottingham.ac.uk&gt;</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 &nbsp; &nbsp;
&nbsp; &nbsp;&lt;coin-discuss@list.coin-or.org&gt;</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">&lt;coin-discuss@list.coin-or.org&gt;</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 &amp; &nbsp; &nbsp; &nbsp; &nbsp; 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 &nbsp;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>
 &nbsp;<br>
 &nbsp;// Get rid of integer stuff<br>
 &nbsp;delete [] integerInformation_;<br>
 &nbsp;integerInformation_=NULL;<br>
<br>
 &nbsp;CoinLpIO m;<br>
 &nbsp;m.setInfinity(getInfinity());<br>
 &nbsp;//m.passInMessageHandler(modelPtr_-&gt;messageHandler());<br>
 &nbsp;//*m.messagesPointer()=modelPtr_-&gt;coinMessages();<br>
 &nbsp;<br>
 &nbsp;//handler_-&gt;message(COIN_SOLVER_MPS,messages_)<br>
 &nbsp;// &nbsp;&lt;&lt;m.getProblemName()&lt;&lt; numberErrors &lt;&lt;CoinMessageEol;<br>
 &nbsp;int numberErrors = 0;<br>
 &nbsp;m.readLp(filename, epsilon);<br>
<br>
 &nbsp;if (!numberErrors) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; // set objective function offest<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; setDblParam(OsiObjOffset, 0);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; // set problem name<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; setStrParam(OsiProbName, m.getProblemName());<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; // no errors<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m.getObjCoefficients(),m.getRowSense(),m.getRightHandSide(),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m.getRowRange());<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; const char *integer = m.integerColumns();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; int nCols = m.getNumCols();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; int nRows = m.getNumRows();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; if (integer) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int
i, n = 0;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int
*index = new int [nCols];<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for
(i=0; i&lt;nCols; i++) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;if (integer[i]) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;index[n++]
= i;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;}<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setInteger(index,n);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;delete
[] index;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; }<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; // Always keep names<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; int iRow;<br>
 &nbsp; &nbsp; &nbsp;std::vector&lt;std::string&gt; rowNames = std::vector&lt;std::string&gt;
();<br>
 &nbsp; &nbsp; &nbsp;std::vector&lt;std::string&gt; columnNames = std::vector&lt;std::string&gt;
();<br>
 &nbsp; &nbsp; &nbsp;rowNames.reserve(nRows);<br>
 &nbsp; &nbsp; &nbsp;for (iRow=0;iRow&lt;nRows;iRow++) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const
char * name = m.rowName(iRow);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rowNames.push_back(name);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; }<br>
 &nbsp; &nbsp;<br>
 &nbsp; &nbsp; &nbsp;int iColumn;<br>
 &nbsp; &nbsp; &nbsp;columnNames.reserve(nCols);<br>
 &nbsp; &nbsp; &nbsp;for (iColumn=0;iColumn&lt;nCols;iColumn++) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const
char * name = m.columnName(iColumn);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;columnNames.push_back(name);<br>
 &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp;modelPtr_-&gt;copyNames(rowNames,columnNames);<br>
 &nbsp;}<br>
 &nbsp;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>
 &nbsp; &nbsp;OsiClpSolverInterface solver0;<br>
 &nbsp; &nbsp;std::string fn = &quot;test2.lp&quot;;<br>
 &nbsp; &nbsp;solver0.readLp(fn.c_str());<br>
 &nbsp; &nbsp;int ncols = solver0.getNumCols();<br>
 &nbsp; &nbsp;for(int i=0;i&lt;ncols;i++) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::cout&lt;&lt;solver0.getColName(i)&lt;&lt;&quot;\n&quot;;}<br>
<br>
This outputs the column names as C0000001 etc. As there is no guarantee
&nbsp;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>