src/work/athos/lp/lp_solver_base.h
author hegyi
Fri, 01 Apr 2005 09:44:29 +0000
changeset 1289 142633fc5014
permissions -rw-r--r--
Graph displayer is now displaying nodes. Edges remain still undisplayed yet.
     1 // -*- c++ -*-
     2 #ifndef LEMON_LP_SOLVER_BASE_H
     3 #define LEMON_LP_SOLVER_BASE_H
     4 
     5 ///\ingroup misc
     6 ///\file
     7 
     8 // #include <stdio.h>
     9 #include <stdlib.h>
    10 #include <iostream>
    11 #include <map>
    12 #include <limits>
    13 // #include <stdio>
    14 //#include <stdlib>
    15 
    16 #include <iostream>
    17 #include <vector>
    18 #include <string>
    19 #include <list>
    20 #include <memory>
    21 #include <utility>
    22 
    23 //#include <lemon/invalid.h>
    24 //#include <expression.h>
    25 //#include <stp.h>
    26 //#include <lemon/max_flow.h>
    27 //#include <augmenting_flow.h>
    28 //#include <iter_map.h>
    29 
    30 using std::cout;
    31 using std::cin;
    32 using std::endl;
    33 
    34 namespace lemon {
    35   
    36   template <typename _Value>
    37   class LpSolverBase {
    38     
    39     /*! @name Uncategorized functions and types (public members)
    40     */
    41     //@{
    42   public:
    43 
    44     //UNCATEGORIZED
    45 
    46     /// \e
    47     typedef _Value Value;
    48     /// \e 
    49     static const Value INF;
    50   public:
    51     /// \e
    52     LpSolverBase() { }
    53     /// \e
    54     virtual ~LpSolverBase() { }
    55 
    56     /*! @name Low level interface (protected members)
    57       Problem manipulating functions in the low level interface
    58     */
    59     //@{
    60   protected:
    61 
    62     //MATRIX MANIPULATING FUNCTIONS
    63 
    64     /// \e
    65     virtual int _addCol() = 0;
    66     /// \e
    67     virtual int _addRow() = 0;
    68     /// \e
    69     virtual void _eraseCol(int i) = 0;
    70     /// \e
    71     virtual void _eraseRow(int i) = 0;
    72     /// \e
    73     virtual void _setRowCoeffs(int i, 
    74 			       const std::vector<std::pair<int, Value> >& coeffs) = 0;
    75     /// \e
    76     /// This routine modifies \c coeffs only by the \c push_back method.
    77     virtual void _getRowCoeffs(int i, 
    78 			       std::vector<std::pair<int, Value> >& coeffs) = 0;
    79     /// \e
    80     virtual void _setColCoeffs(int i, 
    81 			       const std::vector<std::pair<int, Value> >& coeffs) = 0;
    82     /// \e
    83     /// This routine modifies \c coeffs only by the \c push_back method.
    84     virtual void _getColCoeffs(int i, 
    85 			       std::vector<std::pair<int, Value> >& coeffs) = 0;
    86     /// \e
    87     virtual void _setCoeff(int col, int row, Value value) = 0;
    88     /// \e
    89     virtual Value _getCoeff(int col, int row) = 0;
    90     //  public:
    91     //    /// \e
    92     //    enum Bound { FREE, LOWER, UPPER, DOUBLE, FIXED };
    93   protected:
    94     /// \e
    95     /// The lower bound of a variable (column) have to be given by an 
    96     /// extended number of type Value, i.e. a finite number of type 
    97     /// Value or -INF.
    98     virtual void _setColLowerBound(int i, Value value) = 0;
    99     /// \e
   100     /// The lower bound of a variable (column) is an 
   101     /// extended number of type Value, i.e. a finite number of type 
   102     /// Value or -INF.
   103     virtual Value _getColLowerBound(int i) = 0;
   104     /// \e
   105     /// The upper bound of a variable (column) have to be given by an 
   106     /// extended number of type Value, i.e. a finite number of type 
   107     /// Value or INF.
   108     virtual void _setColUpperBound(int i, Value value) = 0;
   109     /// \e
   110     /// The upper bound of a variable (column) is an 
   111     /// extended number of type Value, i.e. a finite number of type 
   112     /// Value or INF.
   113     virtual Value _getColUpperBound(int i) = 0;
   114     /// \e
   115     /// The lower bound of a linear expression (row) have to be given by an 
   116     /// extended number of type Value, i.e. a finite number of type 
   117     /// Value or -INF.
   118     virtual void _setRowLowerBound(int i, Value value) = 0;
   119     /// \e
   120     /// The lower bound of a linear expression (row) is an 
   121     /// extended number of type Value, i.e. a finite number of type 
   122     /// Value or -INF.
   123     virtual Value _getRowLowerBound(int i) = 0;
   124     /// \e
   125     /// The upper bound of a linear expression (row) have to be given by an 
   126     /// extended number of type Value, i.e. a finite number of type 
   127     /// Value or INF.
   128     virtual void _setRowUpperBound(int i, Value value) = 0;
   129     /// \e
   130     /// The upper bound of a linear expression (row) is an 
   131     /// extended number of type Value, i.e. a finite number of type 
   132     /// Value or INF.
   133     virtual Value _getRowUpperBound(int i) = 0;
   134     /// \e
   135     virtual void _setObjCoeff(int i, Value obj_coef) = 0;
   136     /// \e
   137     virtual Value _getObjCoeff(int i) = 0;
   138     
   139     //SOLUTION RETRIEVING
   140 
   141     /// \e
   142     virtual Value _getPrimal(int i) = 0;
   143     //@}
   144     
   145 
   146 
   147     /*! @name MIP functions and types (public members)
   148     */
   149     //@{
   150   protected:
   151    /// \e
   152     virtual void _setColCont(int i) = 0;
   153     /// \e
   154     virtual void _setColInt(int i) = 0;
   155     /// \e
   156     virtual Value _getMIPPrimal(int i) = 0;
   157     //@}
   158   };
   159 
   160 } //namespace lemon
   161 
   162 #endif //LEMON_LP_SOLVER_BASE_H