LpWriter Class Reference
[Tools for Lp and Mip solvers]


Detailed Description

This section reader provides an easy way to write an Lp problem to 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.

If an LP variable does not have name in the writer, then it will automatically created in the writer. This make a slight change in the const variable.

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

      Lp lp;
     
      LemonWriter writer(filename_or_ostream);
      LpWriter lpwriter(writer, lp);
      
      writer.run();

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

Inheritance diagram for LpWriter:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 LpWriter (LemonWriter &_writer, const LpSolverBase &_lp, const std::string &_name=std::string())
 Constructor.
virtual ~LpWriter ()
 Destructor.

Protected Member Functions

virtual std::string header ()
 Gives back true when the SectionWriter can process the section with the given header line.
virtual void write (std::ostream &os)
 Writer function of the section.


Constructor & Destructor Documentation

LpWriter ( LemonWriter _writer,
const LpSolverBase _lp,
const std::string &  _name = std::string() 
) [inline]

Constructor for LpWriter. It creates the LpWriter and attach it into the given LemonWriter.

virtual ~LpWriter (  )  [inline, virtual]

Destructor for LpWriter.


Member Function Documentation

virtual std::string header (  )  [inline, protected, virtual]

It gives back the header line of the @lp section.

Implements SectionWriter.

virtual void write ( std::ostream &  os  )  [inline, protected, virtual]

It writes the content of the section.

Implements SectionWriter.


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