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

Francois Margot fmargot at andrew.cmu.edu
Fri Apr 21 15:48:39 EDT 2006


I indeed have to correct that. The CoinLpIO reader has the original
names available through the methods getRowNames() and getColNames(),
provided that the original names are "valid" (see the definition
of such names in the doc for the method COinLpIO::is_invalid_name()).

To print the column names (similar for row names) from OsiClp, you can use

   for(int jj =0; jj<clp->getNumCols(); jj++) {
     std::string columnName = clp->getColName(jj);
     printf("%s\n", columnName.c_str());
   }

There might be a method for getting all names in one vector, but
I could not find it.

Francois


On Fri, 21 Apr 2006, Laszlo Ladanyi wrote:

> 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
>
>
>



More information about the Coin-discuss mailing list