[Coin-discuss] how to get variable names in CPLEX LP format using OSI?

Pu Huang puhuang at us.ibm.com
Fri Apr 21 14:03:46 EDT 2006


Hi, Laci,

Thanks for your reply. I rewrote the readLp() method, replaced its local 
variable "COINLpIO m" by a COINLpIO pointer passed in, from this pointer, 
I can extract variable names by calling COINLpIO::columnName() method. 
This workaround seems to work, but I am not sure whether the variable 
names I got are arranged in the same order as the solution I got from 
calling OsiSolverInterface::getColsolution().   Can Francois please answer 
this question?


-------------------------------------------------

si=OsiSolverInterface;
si= new OsiClpSolverInterface; 
COINLpIO * rPrt = new COINLpIO();

si->readLp(rPrt, "t1.lp");   <--------the new readLp() method

// solve the problem
 
int n=si->getNumcols();
solution =si->getColsolution();
for(int i=0;i<n; i++){
           const char *name=rPrt->columnName(i);  <-----------Is it right 
to do so?
         cout<<name<<" = "<<solution[i]<<endl; 
}
-------------------------------------


Cheers
Paul
 






ladanyi at watson.ibm.com 
Sent by: coin-discuss-bounces at list.coin-or.org
04/21/2006 01:24 PM
Please respond to
Discussions about open source software for Operations Research 
<coin-discuss at list.coin-or.org>


To
Discussions about open source software for Operations Research 
<coin-discuss at list.coin-or.org>
cc
Francois Margot <fmargot at andrew.cmu.edu>
Subject
Re: [Coin-discuss] how to get variable names in CPLEX LP format using OSI?






Hi Paul,

The bad news: as far as I know (but Francois may correct me) the LP format
reader loses the variable names... :-(

Sorry,
--Laci

On Thu, 20 Apr 2006, Pu Huang wrote:

> If someone uses OsiSolverInterface::readLp() to read a problem instance 
in 
> CPLEX LP format and subsequently solve the problem. How to extract the 
> variable names from the solutions?
> 
> ------------------------------------
> 
> si=OsiSolverInterface;
> si= new OsiClpSolverInterface; 
> si->readLp("t1.lp");
> 
> // solve the problem
> 
> int n=si->getNumcols();
> solution =si->getColsolution();
> for(int i=0;i<n, i++){
>            string name=si->?????? (what function to call?)
>         cout<<name<<" = "<<solution[i]<<endl;
> }
> -------------------------------------
> 
> I tried OsiSolverInterface::getColName(), but it returns names like 
> "C000001", not the original variable names in the LP file. 
> 
> Cheers
> Paul Huang

_______________________________________________
Coin-discuss mailing list
Coin-discuss at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/coin-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20060421/36be5799/attachment.html>


More information about the Coin-discuss mailing list