LpReader Class Reference
[Tools for Lp and Mip solvers]


Detailed Description

This section reader provides an easy way to read an Lp problem from a file. The lemon lp section format contains three parts.

      @lp
      constraints
        7 == x1 - 1 * x2
        2 * x1 + x3 / 2 <= 7
        x2 + -3 * x3 >= 8
        3 <= x2 - 2 * x1 <= 8
      bounds
        x1 >= 3
        2 <= x2 <= 5
        0 <= x3 <= 8
      objective
        min x1 + 2 * x2 - x3

The first part gives the constraints to the lp. The constraints could be equality, lower bound, upper bound or range for an expression or equality, less or more for two expressions.

The second part gives the bounds for the variables. The bounds could be the same as for the single expression so equality, lower bound, upper bound or range.

The third part is the objective function, it should start with min or max and then a valid linear expression.

The reader constructs automatically the variable for a name if there is not already a variable with the same name.

The basic way to read an LP problem is made by the next code:

      Lp lp;
     
      LemonReader reader(filename_or_istream);
      LpReader lpreader(reader, lp);
      
      reader.run();

Of course instead of LemonReader you can give a GraphReader to the LpReader constructor. Also useful that you can mix lp problems and graphs in the same file. #include <lemon/lp_utils.h>

Inheritance diagram for LpReader:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 LpReader (LemonReader &_reader, LpSolverBase &_lp, const std::string &_name=std::string())
 Constructor.
virtual ~LpReader ()
 Destructor.

Protected Member Functions

virtual bool header (const std::string &line)
 Gives back true when the SectionReader can process the section with the given header line.
virtual void read (std::istream &is)
 Reader function of the section.


Constructor & Destructor Documentation

LpReader ( LemonReader _reader,
LpSolverBase _lp,
const std::string &  _name = std::string() 
) [inline]

Constructor for LpReader. It creates the LpReader and attachs it into the given LemonReader. The lp reader will add variables, constraints and objective function to the given lp solver.

virtual ~LpReader (  )  [inline, virtual]

Destructor for LpReader.


Member Function Documentation

virtual bool header ( const std::string &  line  )  [inline, protected, virtual]

It gives back true when the header line starts with @lp, and the header line's name and the nodeset's name are the same.

Implements SectionReader.

virtual void read ( std::istream &  is  )  [inline, protected, virtual]

It reads the content of the section.

Implements SectionReader.


Generated on Thu Jun 4 04:05:17 2009 for LEMON by  doxygen 1.5.9